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

Prettier fix (#8754)

上级 a0341ea1
......@@ -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>
</>
......
......@@ -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
......@@ -129,5 +134,3 @@ 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
......@@ -142,5 +147,3 @@ 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,8 +44,8 @@ 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) |
| -- | -- | -- |
| Part | Source code (Typescript) | Builds (JavaScript) |
| ---------- | ------------------------ | ------------------- |
| Next.js | `/renderer` | `/renderer` |
| Electron | `/electron-src` | `/main` |
| Production | | `/dist` |
......@@ -54,6 +55,7 @@ For development it's going to run a HTTP server and let Next.js handle routing.
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;
export default function(
directories: Directories | string,
port?: number
): adjustRenderer | devServer
}
......@@ -16,8 +16,8 @@ app.on('ready', async () => {
height: 600,
webPreferences: {
nodeIntegration: false,
preload: join(__dirname, 'preload.js')
}
preload: join(__dirname, 'preload.js'),
},
})
const url = isDev
......@@ -25,7 +25,7 @@ app.on('ready', async () => {
: format({
pathname: join(__dirname, '../renderer/index.html'),
protocol: 'file:',
slashes: true
slashes: true,
})
mainWindow.loadURL(url)
......
......@@ -3,7 +3,7 @@ import { ipcRenderer, IpcRenderer } from 'electron'
declare global {
namespace NodeJS {
interface Global {
ipcRenderer: IpcRenderer;
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"]
}
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 }]
}
......@@ -45,7 +45,7 @@ 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).
- 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.
先完成此消息的编辑!
想要评论请 注册