提交 7863b60e 编写于 作者: L Lukáš Huvar 提交者: Tim Neutkens

Prettier fix (#8754)

上级 a0341ea1
......@@ -5,7 +5,7 @@ jobs:
name: PR Stats
runs-on: ubuntu-latest
steps:
- name: PR Stats
uses: zeit/next-stats-action@master
env:
COMMENT_ENDPOINT: https://next-stats.jjsweb.site/api/comment
- name: PR Stats
uses: zeit/next-stats-action@master
env:
COMMENT_ENDPOINT: https://next-stats.jjsweb.site/api/comment
......@@ -5,7 +5,7 @@ jobs:
name: PR Stats
runs-on: ubuntu-latest
steps:
- name: PR Stats
uses: zeit/next-stats-action@master
env:
PR_STATS_COMMENT_TOKEN: ${{ secrets.PR_STATS_COMMENT_TOKEN }}
- name: PR Stats
uses: zeit/next-stats-action@master
env:
PR_STATS_COMMENT_TOKEN: ${{ secrets.PR_STATS_COMMENT_TOKEN }}
......@@ -10,6 +10,7 @@ This handling has been moved up the tree so the `<Container>` component is no lo
Remove the `<Container>` component from your Custom `<App>` (`./pages/_app.js`).
**Before**
```jsx
import React from 'react'
import App, { Container } from 'next/app'
......@@ -29,6 +30,7 @@ export default MyApp
```
**After**
```jsx
import React from 'react'
import App from 'next/app'
......
......@@ -7,12 +7,13 @@ Somewhere you are utilizing the `next/link` component, `Router#push`, or `Router
Note: this error will only show when the `next/link` component is clicked not when only rendered.
**Incompatible `href` and `as`**
```jsx
import Link from 'next/link'
export default () => (
<>
<Link href='/[post]' as='/post-1/comments'>
<Link href="/[post]" as="/post-1/comments">
<a>Invalid link</a>
</Link>
</>
......@@ -20,12 +21,13 @@ export default () => (
```
**Compatible `href` and `as`**
```jsx
import Link from 'next/link'
export default () => (
<>
<Link href='/[post]' as='/post-1'>
<Link href="/[post]" as="/post-1">
<a>Valid link</a>
</Link>
</>
......
......@@ -2,7 +2,7 @@
#### Why This Error Occurred
Next.js provides a router which can be utilized via a component imported via `next/link`, a wrapper `withRouter(Component)`, and now a hook `useRouter()`.
Next.js provides a router which can be utilized via a component imported via `next/link`, a wrapper `withRouter(Component)`, and now a hook `useRouter()`.
When using any of these, it is expected they are only used for internal navigation, i.e. navigating between pages in the same Next.js application.
Either you passed a non-internal `href` to a `next/link` component or you called `Router#push` or `Router#replace` with one.
......
......@@ -12,4 +12,3 @@ This severely degrades your application's performance at runtime. It can also re
Be sure your `next.config.js` has not modified `optimization.minimize` or `optimization.minimizer`.
You can file an issue on our GitHub if you do not understand why minification is being disabled by your `next.config.js`.
......@@ -3,10 +3,7 @@
"target": "esnext",
"module": "esnext",
"jsx": "preserve",
"lib": [
"dom",
"es2017"
],
"lib": ["dom", "es2017"],
"baseUrl": ".",
"moduleResolution": "node",
"strict": true,
......@@ -24,15 +21,6 @@
"forceConsistentCasingInFileNames": true,
"resolveJsonModule": true
},
"exclude": [
"dist",
".next",
"out",
"next.config.js"
],
"include": [
"next-env.d.ts",
"**/*.ts",
"**/*.tsx"
]
"exclude": ["dist", ".next", "out", "next.config.js"],
"include": ["next-env.d.ts", "**/*.ts", "**/*.tsx"]
}
......@@ -30,16 +30,21 @@ cd with-aws-amplify-typescript
#### Install & Configure Amplify
1. [Sign up](https://portal.aws.amazon.com/billing/signup#/start) for an AWS account
2. Install the AWS Amplify cli:
```sh
1. [Sign up](https://portal.aws.amazon.com/billing/signup#/start) for an AWS account
2. Install the AWS Amplify cli:
```sh
npm install -g @aws-amplify/cli
```
3. Configure the Amplify cli
```sh
```
3. Configure the Amplify cli
```sh
amplify configure
```
[Read More](https://aws-amplify.github.io/docs/cli-toolchain/quickstart?sdk=js)
```
[Read More](https://aws-amplify.github.io/docs/cli-toolchain/quickstart?sdk=js)
</details>
#### Initialize Amplify
......@@ -52,9 +57,9 @@ $ amplify init
? Enter a name for the environment: dev (or whatever you would like to call this env)
? Choose your default editor: <YOUR_EDITOR_OF_CHOICE>
? Choose the type of app that you're building (Use arrow keys)
android
ios
❯ javascript
android
ios
❯ javascript
? What javascript framework are you using react
? Source Directory Path: src
? Distribution Directory Path: out
......@@ -71,11 +76,11 @@ $ amplify init
$ amplify add api
# <Interactive>
? Please select from one of the below mentioned services (Use arrow keys)
❯ GraphQL
REST
❯ GraphQL
REST
? Provide API name: <API_NAME>
? Choose an authorization type for the API (Use arrow keys)
❯ API key
❯ API key
Amazon Cognito User Pool
? Do you have an annotated GraphQL schema? (y/N) y
? Provide your schema file path: ./schema.graphql
......@@ -90,12 +95,12 @@ $ amplify push
? Are you sure you want to continue? Y
? Do you want to generate code for your newly created GraphQL API? Y
? Choose the code generation language target (Use arrow keys)
javascript
❯ typescript
javascript
❯ typescript
flow
? Enter the file name pattern of graphql queries, mutations and subscriptions (src/graphql/**/*.js)
? Enter the file name pattern of graphql queries, mutations and subscriptions (src/graphql/**/*.js)
? Do you want to generate/update all possible GraphQL operations - queries, mutations and subscriptions (Y/n) Y
? Enter maximum statement depth [increase from default if your schema is deeply nested] (2)
? Enter maximum statement depth [increase from default if your schema is deeply nested] (2)
# </Interactive>
```
......@@ -114,7 +119,7 @@ yarn dev
1. Open [`amplify/backend/api/nextjswithamplifyts/schema.graphql`](amplify/backend/api/nextjswithamplifyts/schema.graphql) and change what you need to.
2. Run `amplify push`
3. 👍
3. 👍
## The idea behind the example
......@@ -124,10 +129,8 @@ We use AWS Amplify to generate code and to manage and consume the AWS cloud reso
The NextJS app has dynamic and static routes to demonstrate how to load data on the server based on the incoming request.
Two routes are implemented :
Two routes are implemented :
- `/` : A static route that uses getInitialProps to load data from AppSync and renders it on the server (Code in [pages/index.tsx](/pages/index.tsx))
- `/todo/[id]` : A dynamic route that uses getInitialProps and the id from the provided context to load a single todo from AppSync and render it on the server. (Code in [pages/todo/:[id].tsx](/pages/todo/[id].tsx))
{
"compilerOptions": {
"target": "es5",
"lib": [
"dom",
"dom.iterable",
"esnext"
],
"lib": ["dom", "dom.iterable", "esnext"],
"allowJs": true,
"skipLibCheck": true,
"strict": false,
......@@ -18,12 +14,6 @@
"isolatedModules": true,
"jsx": "preserve"
},
"exclude": [
"node_modules"
],
"include": [
"next-env.d.ts",
"**/*.ts",
"**/*.tsx"
]
"exclude": ["node_modules"],
"include": ["next-env.d.ts", "**/*.ts", "**/*.tsx"]
}
......@@ -30,16 +30,21 @@ cd with-aws-amplify
#### Install & Configure Amplify
1. [Sign up](https://portal.aws.amazon.com/billing/signup#/start) for an AWS account
2. Install the AWS Amplify cli:
```sh
1. [Sign up](https://portal.aws.amazon.com/billing/signup#/start) for an AWS account
2. Install the AWS Amplify cli:
```sh
npm install -g @aws-amplify/cli
```
3. Configure the Amplify cli
```sh
```
3. Configure the Amplify cli
```sh
amplify configure
```
[Read More](https://aws-amplify.github.io/docs/cli-toolchain/quickstart?sdk=js)
```
[Read More](https://aws-amplify.github.io/docs/cli-toolchain/quickstart?sdk=js)
</details>
#### Initialize Amplify
......@@ -52,9 +57,9 @@ $ amplify init
? Enter a name for the environment: dev (or whatever you would like to call this env)
? Choose your default editor: <YOUR_EDITOR_OF_CHOICE>
? Choose the type of app that you're building (Use arrow keys)
android
ios
❯ javascript
android
ios
❯ javascript
? What javascript framework are you using react
? Source Directory Path: src
? Distribution Directory Path: out
......@@ -71,11 +76,11 @@ $ amplify init
$ amplify add api
# <Interactive>
? Please select from one of the below mentioned services (Use arrow keys)
❯ GraphQL
REST
❯ GraphQL
REST
? Provide API name: <API_NAME>
? Choose an authorization type for the API (Use arrow keys)
❯ API key
❯ API key
Amazon Cognito User Pool
? Do you have an annotated GraphQL schema? (y/N) y
? Provide your schema file path: ./schema.graphql
......@@ -90,12 +95,12 @@ $ amplify push
? Are you sure you want to continue? Y
? Do you want to generate code for your newly created GraphQL API? Y
? Choose the code generation language target (Use arrow keys)
❯ javascript
typescript
❯ javascript
typescript
flow
? Enter the file name pattern of graphql queries, mutations and subscriptions (src/graphql/**/*.js)
? Enter the file name pattern of graphql queries, mutations and subscriptions (src/graphql/**/*.js)
? Do you want to generate/update all possible GraphQL operations - queries, mutations and subscriptions (Y/n) Y
? Enter maximum statement depth [increase from default if your schema is deeply nested] (2)
? Enter maximum statement depth [increase from default if your schema is deeply nested] (2)
# </Interactive>
```
......@@ -114,7 +119,7 @@ yarn dev
1. Open `amplify/backend/api/projectname/schema.graphql` and change what you need to.
2. Run `amplify push`
3. 👍
3. 👍
### Use with new Amplify project
......@@ -123,8 +128,8 @@ Make sure to commit your changes before doing this.
```sh
mv amplify/backend/api/nextjswithawsamplify/schema.graphql ./schema.graphql
rm -rf amplify/ src/
amplify init
amplify add api
amplify init
amplify add api
rm ./schema.graphql
amplify push
```
......@@ -137,10 +142,8 @@ We use AWS Amplify to generate code and to manage and consume the AWS cloud reso
The NextJS app has dynamic and static routes to demonstrate how to load data on the server based on the incoming request.
Two routes are implemented :
Two routes are implemented :
- `/` : A static route that uses getInitialProps to load data from AppSync and renders it on the server (Code in [pages/index.js](/pages/index.js))
- `/todo/[id]` : A dynamic route that uses getInitialProps and the id from the provided context to load a single todo from AppSync and render it on the server. (Code in [pages/todo/:[id].js](/pages/todo/[id].js))
......@@ -24,6 +24,7 @@ cd with-electron-typescript
```
To install and start dev build:
```bash
yarn install && yarn build && yarn start
```
......@@ -43,17 +44,18 @@ Available commands:
This example show how you can use Next.js inside an Electron application to avoid a lot of configuration, use Next.js router as view and use server-render to speed up the initial render of the application. Both Next.js and Electron layers are written in TypeScript and compiled to JavaScript during the build process.
| Part| Source code (Typescript) | Builds (JavaScript) |
| -- | -- | -- |
| Next.js | `/renderer` | `/renderer` |
| Electron | `/electron-src` | `/main` |
| Production | | `/dist` |
| Part | Source code (Typescript) | Builds (JavaScript) |
| ---------- | ------------------------ | ------------------- |
| Next.js | `/renderer` | `/renderer` |
| Electron | `/electron-src` | `/main` |
| Production | | `/dist` |
For development it's going to run a HTTP server and let Next.js handle routing. In production it use `next export` to pre-generate HTML static files and use them in your app instead of running an HTTP server.
You can create the production app using `npm run dist`.
_note regarding types:_
* Electron provides its own type definitions, so you don't need @types/electron installed!
source: https://www.npmjs.com/package/@types/electron
* There were no types available for `electron-next` at the time of creating this example, so until they are available there is a file `electron-next.d.ts` in `electron-src` directory.
- Electron provides its own type definitions, so you don't need @types/electron installed!
source: https://www.npmjs.com/package/@types/electron
- There were no types available for `electron-next` at the time of creating this example, so until they are available there is a file `electron-next.d.ts` in `electron-src` directory.
declare module "electron-next" {
declare module 'electron-next' {
function adjustRenderer(directory: string): void
function adjustRenderer (directory: string): void;
function devServer (dir: string, port?: number): void;
function devServer(dir: string, port?: number): void
interface Directories {
production: string,
production: string
development: string
}
export default function(directories: Directories | string, port?: number): adjustRenderer | devServer;
}
\ No newline at end of file
export default function(
directories: Directories | string,
port?: number
): adjustRenderer | devServer
}
......@@ -16,17 +16,17 @@ app.on('ready', async () => {
height: 600,
webPreferences: {
nodeIntegration: false,
preload: join(__dirname, 'preload.js')
}
preload: join(__dirname, 'preload.js'),
},
})
const url = isDev
? 'http://localhost:8000/'
: format({
pathname: join(__dirname, '../renderer/index.html'),
protocol: 'file:',
slashes: true
})
pathname: join(__dirname, '../renderer/index.html'),
protocol: 'file:',
slashes: true,
})
mainWindow.loadURL(url)
})
......
......@@ -2,9 +2,9 @@ import { ipcRenderer, IpcRenderer } from 'electron'
declare global {
namespace NodeJS {
interface Global {
ipcRenderer: IpcRenderer;
}
interface Global {
ipcRenderer: IpcRenderer
}
}
}
......
......@@ -6,10 +6,7 @@
"forceConsistentCasingInFileNames": true,
"isolatedModules": true,
"jsx": "preserve",
"lib": [
"dom",
"es2017"
],
"lib": ["dom", "es2017"],
"module": "commonjs",
"moduleResolution": "node",
"noEmit": false,
......@@ -20,14 +17,8 @@
"skipLibCheck": true,
"strict": true,
"target": "esnext",
"outDir": "../main",
"outDir": "../main"
},
"exclude": [
"node_modules"
],
"include": [
"**/*.ts",
"**/*.tsx",
"**/*.js"
]
"exclude": ["node_modules"],
"include": ["**/*.ts", "**/*.tsx", "**/*.js"]
}
......@@ -6,10 +6,7 @@
"forceConsistentCasingInFileNames": true,
"isolatedModules": true,
"jsx": "preserve",
"lib": [
"dom",
"es2017"
],
"lib": ["dom", "es2017"],
"module": "esnext",
"moduleResolution": "node",
"noEmit": true,
......@@ -21,12 +18,6 @@
"strict": true,
"target": "esnext"
},
"exclude": [
"node_modules"
],
"include": [
"**/*.ts",
"**/*.tsx",
"**/*.js"
]
"exclude": ["node_modules"],
"include": ["**/*.ts", "**/*.tsx", "**/*.js"]
}
......@@ -16,23 +16,13 @@
"skipLibCheck": true,
"sourceMap": true,
"noEmit": true,
"lib": [
"es6",
"dom",
"es2016"
],
"lib": ["es6", "dom", "es2016"],
"baseUrl": ".",
"forceConsistentCasingInFileNames": true,
"esModuleInterop": true,
"resolveJsonModule": true,
"isolatedModules": true
},
"exclude": [
"node_modules"
],
"include": [
"next-env.d.ts",
"**/*.ts",
"**/*.tsx"
]
"exclude": ["node_modules"],
"include": ["next-env.d.ts", "**/*.ts", "**/*.tsx"]
}
{
"compilerOptions": {
"lib": [
"es6",
"dom",
"es2016"
],
"lib": ["es6", "dom", "es2016"],
"module": "commonjs",
"strict": true,
"outDir": "../../dist/functions",
......
......@@ -14,14 +14,8 @@
"sourceMap": true,
"skipLibCheck": true,
"baseUrl": ".",
"typeRoots": [
"./node_modules/@types"
],
"lib": [
"dom",
"es2015",
"es2016"
],
"typeRoots": ["./node_modules/@types"],
"lib": ["dom", "es2015", "es2016"],
"strict": false,
"forceConsistentCasingInFileNames": true,
"noEmit": true,
......@@ -36,9 +30,5 @@
"**/*.test.ts",
"**/*.test.tsx"
],
"include": [
"next-env.d.ts",
"**/*.ts",
"**/*.tsx"
]
"include": ["next-env.d.ts", "**/*.ts", "**/*.tsx"]
}
......@@ -4,4 +4,4 @@
"nav.about": "About",
"description": "An example app integrating React Intl with Next.js",
"greeting": "Hello, World!"
}
\ No newline at end of file
}
import { FormattedMessage, FormattedNumber, defineMessages, useIntl } from 'react-intl'
import {
FormattedMessage,
FormattedNumber,
defineMessages,
useIntl
} from 'react-intl'
import Head from 'next/head'
import Layout from '../components/Layout'
......
......@@ -27,7 +27,9 @@ const localeDataCache = new Map()
const getLocaleDataScript = locale => {
const lang = locale.split('-')[0]
if (!localeDataCache.has(lang)) {
const localeDataFile = require.resolve(`@formatjs/intl-relativetimeformat/dist/locale-data/${lang}`)
const localeDataFile = require.resolve(
`@formatjs/intl-relativetimeformat/dist/locale-data/${lang}`
)
const localeDataScript = readFileSync(localeDataFile, 'utf8')
localeDataCache.set(lang, localeDataScript)
}
......
......@@ -3,10 +3,7 @@
"target": "esnext",
"module": "esnext",
"jsx": "preserve",
"lib": [
"dom",
"es2017"
],
"lib": ["dom", "es2017"],
"moduleResolution": "node",
"allowJs": true,
"noEmit": true,
......@@ -23,12 +20,6 @@
"resolveJsonModule": true,
"isolatedModules": true
},
"exclude": [
"node_modules"
],
"include": [
"next-env.d.ts",
"**/*.ts",
"**/*.tsx"
]
"exclude": ["node_modules"],
"include": ["next-env.d.ts", "**/*.ts", "**/*.tsx"]
}
......@@ -6,10 +6,7 @@
"forceConsistentCasingInFileNames": true,
"isolatedModules": true,
"jsx": "preserve",
"lib": [
"dom",
"es2017"
],
"lib": ["dom", "es2017"],
"module": "esnext",
"moduleResolution": "node",
"noEmit": true,
......@@ -21,11 +18,6 @@
"strict": true,
"target": "esnext"
},
"exclude": [
"node_modules"
],
"include": [
"**/*.ts",
"**/*.tsx"
]
"exclude": ["node_modules"],
"include": ["**/*.ts", "**/*.tsx"]
}
{
"version": 2,
"builds": [
{ "src": "packages/web-app/package.json", "use": "@now/next" }
],
"routes": [
{ "src": "(.*)", "dest": "packages/web-app$1", "continue": true }
]
"builds": [{ "src": "packages/web-app/package.json", "use": "@now/next" }],
"routes": [{ "src": "(.*)", "dest": "packages/web-app$1", "continue": true }]
}
......@@ -44,8 +44,8 @@ yarn dev
- All pages should be unique across zones. For example, the 'home' app should not have a `pages/blog/index.js` page.
- The 'blog' app sets `assetPrefix` so that generated JS bundles are within the `/blog` subfolder.
- To also support the plain `next dev` scenario, `assetPrefix` is set dynamically based on the `BUILDING_FOR_NOW` environment variable, see [`now.json`](now.json) and [`blog/next.config.js`](blog/next.config.js).
- Images and other `/static` assets have to be prefixed manually, e.g., ``<img src={`${process.env.ASSET_PREFIX}/static/image.png`} />``, see [`blog/pages/blog/index.js`](blog/pages/blog/index.js).
- To also support the plain `next dev` scenario, `assetPrefix` is set dynamically based on the `BUILDING_FOR_NOW` environment variable, see [`now.json`](now.json) and [`blog/next.config.js`](blog/next.config.js).
- Images and other `/static` assets have to be prefixed manually, e.g., `` <img src={`${process.env.ASSET_PREFIX}/static/image.png`} /> ``, see [`blog/pages/blog/index.js`](blog/pages/blog/index.js).
## Production Deployment
......
{
"npmClient": "yarn",
"useWorkspaces": true,
"packages": [
"packages/*"
],
"packages": ["packages/*"],
"command": {
"version": {
"exact": true
},
"publish": {
"npmClient": "npm",
"allowBranch": [
"master",
"canary"
],
"allowBranch": ["master", "canary"],
"registry": "https://registry.npmjs.org/"
}
},
......
......@@ -2164,8 +2164,8 @@ In some cases this indicator might not be as useful like when working on electro
```js
module.exports = {
devIndicators: {
autoPrerender: false
}
autoPrerender: false,
},
}
```
......
{
"compilerOptions": {
"target": "es5",
"lib": [
"dom",
"dom.iterable",
"esnext"
],
"lib": ["dom", "dom.iterable", "esnext"],
"allowJs": true,
"skipLibCheck": true,
"strict": false,
......@@ -18,12 +14,6 @@
"isolatedModules": true,
"jsx": "preserve"
},
"exclude": [
"node_modules"
],
"include": [
"next-env.d.ts",
"**/*.ts",
"**/*.tsx"
]
"exclude": ["node_modules"],
"include": ["next-env.d.ts", "**/*.ts", "**/*.tsx"]
}
......@@ -4,11 +4,7 @@
"module": "esnext",
"jsx": "preserve",
"target": "es5",
"lib": [
"dom",
"dom.iterable",
"esnext"
],
"lib": ["dom", "dom.iterable", "esnext"],
"allowJs": true,
"skipLibCheck": true,
"strict": false,
......@@ -18,12 +14,6 @@
"resolveJsonModule": true,
"isolatedModules": true
},
"exclude": [
"node_modules"
],
"include": [
"next-env.d.ts",
"**/*.ts",
"**/*.tsx"
]
"exclude": ["node_modules"],
"include": ["next-env.d.ts", "**/*.ts", "**/*.tsx"]
}
{
"compilerOptions": {
"target": "es5",
"lib": [
"dom",
"dom.iterable",
"esnext"
],
"lib": ["dom", "dom.iterable", "esnext"],
"allowJs": true,
"skipLibCheck": true,
"strict": false,
......@@ -18,12 +14,6 @@
"isolatedModules": true,
"jsx": "preserve"
},
"exclude": [
"node_modules"
],
"include": [
"next-env.d.ts",
"**/*.ts",
"**/*.tsx"
]
"exclude": ["node_modules"],
"include": ["next-env.d.ts", "**/*.ts", "**/*.tsx"]
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册