-
Notifications
You must be signed in to change notification settings - Fork 27.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'canary' into feature/dont-swallow-module-not-found-error
- Loading branch information
Showing
77 changed files
with
1,152 additions
and
1,955 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
# No CSS Tags | ||
|
||
### Why This Error Occurred | ||
|
||
An HTML link element was used to link to an external stylesheet. This can negatively affect CSS resource loading on your web page. | ||
|
||
### Possible Ways to Fix It | ||
|
||
There are multiple ways to include styles using Next.js' built-in CSS support, including the option to use `@import` within the root stylesheet that is imported in `pages/_app.js`: | ||
|
||
```css | ||
/* Root stylesheet */ | ||
@import 'extra.css'; | ||
|
||
body { | ||
/* ... */ | ||
} | ||
``` | ||
|
||
Another option is to use CSS Modules to import the CSS file scoped specifically to the component. | ||
|
||
```jsx | ||
import styles from './extra.module.css' | ||
|
||
export class Home { | ||
render() { | ||
return ( | ||
<div> | ||
<button type="button" className={styles.active}> | ||
Open | ||
</button> | ||
</div> | ||
) | ||
} | ||
} | ||
``` | ||
|
||
Refer to the [Built-In CSS Support](https://nextjs.org/docs/basic-features/built-in-css-support) documentation to learn about all the ways to include CSS to your application. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
# No HTML link for pages | ||
|
||
### Why This Error Occurred | ||
|
||
An HTML anchor element, `<a>`, was used to navigate to a page route without using the `Link` component. | ||
|
||
The `Link` component is required in order to enable client-side route transitions between pages and provide a single-page app experience. | ||
|
||
### Possible Ways to Fix It | ||
|
||
Make sure to import the `Link` component and wrap anchor elements that route to different page routes. | ||
|
||
**Before:** | ||
|
||
```jsx | ||
function Home() { | ||
return ( | ||
<div> | ||
<a href="/about">About Us</a> | ||
</div> | ||
) | ||
} | ||
``` | ||
|
||
**After:** | ||
|
||
```jsx | ||
import Link from 'next/link' | ||
|
||
function Home() { | ||
return ( | ||
<div> | ||
<Link href="/about"> | ||
<a>About Us</a> | ||
</Link> | ||
</div> | ||
) | ||
} | ||
|
||
export default Home | ||
``` | ||
|
||
### Useful Links | ||
|
||
- [next/link API Reference](https://nextjs.org/docs/api-reference/next/link) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
# No Sync Scripts | ||
|
||
### Why This Error Occurred | ||
|
||
A synchronous script was used which can impact your webpage's performance. | ||
|
||
### Possible Ways to Fix It | ||
|
||
#### Script component (experimental) | ||
|
||
Use the Script component with the right loading strategy to defer loading of the script until necessary. | ||
|
||
```jsx | ||
import Script from 'next/experimental-script' | ||
|
||
const Home = () => { | ||
return ( | ||
<div class="container"> | ||
<Script src="https://third-party-script.js" strategy="defer"></Script> | ||
<div>Home Page</div> | ||
</div> | ||
) | ||
} | ||
|
||
export default Home | ||
``` | ||
|
||
Note: This is still an experimental feature and needs to be enabled via the `experimental.scriptLoader` flag in `next.config.js`. | ||
|
||
### Useful Links | ||
|
||
- [Efficiently load third-party JavaScript](https://web.dev/efficiently-load-third-party-javascript/) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
# Duplicate Polyfills from Polyfill.io | ||
|
||
#### Why This Error Occurred | ||
|
||
You are using Polyfill.io and including duplicate polyfills already shipped with Next.js. This increases page weight unnecessarily which can affect loading performance. | ||
|
||
#### Possible Ways to Fix It | ||
|
||
Remove all duplicate polyfills that are included with Polyfill.io. If you need to add polyfills but are not sure if Next.js already includes it, take a look at the list of [supported browsers and features](https://nextjs.org/docs/basic-features/supported-browsers-features) first. | ||
|
||
### Useful Links | ||
|
||
- [Supported Browsers and Features](https://nextjs.org/docs/basic-features/supported-browsers-features) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{ | ||
"extends": "next", | ||
"root": true | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files. | ||
|
||
# dependencies | ||
/node_modules | ||
/.pnp | ||
.pnp.js | ||
|
||
# testing | ||
/coverage | ||
|
||
# next.js | ||
/.next/ | ||
/out/ | ||
|
||
# production | ||
/build | ||
|
||
# misc | ||
.DS_Store | ||
*.pem | ||
|
||
# debug | ||
npm-debug.log* | ||
yarn-debug.log* | ||
yarn-error.log* | ||
|
||
# local env files | ||
.env.local | ||
.env.development.local | ||
.env.test.local | ||
.env.production.local | ||
|
||
# vercel | ||
.vercel |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# ESLint Example | ||
|
||
This example shows a Next.js application using the built-in ESLint setup with the `next` shareable configuration enabled in `.eslintrc`. | ||
|
||
Note: ESLint running during build (`next build`) is still experimental and needs to be enabled via an `{ experimental: eslint }` flag in `next.config.js`. | ||
|
||
## Deploy your own | ||
|
||
Deploy the example using [Vercel](https://vercel.com?utm_source=github&utm_medium=readme&utm_campaign=next-example): | ||
|
||
[![Deploy with Vercel](https://vercel.com/button)](https://vercel.com/new/git/external?repository-url=https://github.com/vercel/next.js/tree/canary/examples/with-service-worker&project-name=with-service-worker&repository-name=with-service-worker) | ||
|
||
## How to use | ||
|
||
Execute [`create-next-app`](https://github.com/vercel/next.js/tree/canary/packages/create-next-app) with [npm](https://docs.npmjs.com/cli/init) or [Yarn](https://yarnpkg.com/lang/en/docs/cli/create/) to bootstrap the example: | ||
|
||
```bash | ||
npx create-next-app --example with-eslint with-eslint | ||
# or | ||
yarn create next-app --example with-eslint with-eslint | ||
``` | ||
|
||
Deploy it to the cloud with [Vercel](https://vercel.com/new?utm_source=github&utm_medium=readme&utm_campaign=next-example) ([Documentation](https://nextjs.org/docs/deployment)). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
module.exports = { | ||
experimental: { | ||
eslint: true, | ||
}, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
{ | ||
"name": "with-eslint", | ||
"version": "1.0.0", | ||
"scripts": { | ||
"dev": "next", | ||
"build": "next build", | ||
"start": "next start" | ||
}, | ||
"license": "MIT", | ||
"dependencies": { | ||
"next": "latest", | ||
"react": "^17.0.1", | ||
"react-dom": "^17.0.1" | ||
}, | ||
"devDependencies": { | ||
"eslint": "^7.24.0", | ||
"eslint-config-next": "latest" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
const Home = () => ( | ||
<div> | ||
<script src="https://fake-script.com" /> | ||
<p>Home</p> | ||
</div> | ||
) | ||
|
||
export default Home |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,5 +17,5 @@ | |
"registry": "https://registry.npmjs.org/" | ||
} | ||
}, | ||
"version": "10.2.0" | ||
"version": "10.2.1-canary.1" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
{ | ||
"name": "create-next-app", | ||
"version": "10.2.0", | ||
"version": "10.2.1-canary.1", | ||
"keywords": [ | ||
"react", | ||
"next", | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
/* | ||
* @rushstack/eslint-patch is used to include plugins as dev | ||
* dependencies instead of imposing them as peer dependencies | ||
* | ||
* https://www.npmjs.com/package/@rushstack/eslint-patch | ||
*/ | ||
require('@rushstack/eslint-patch/modern-module-resolution') | ||
|
||
module.exports = { | ||
extends: [ | ||
'plugin:react/recommended', | ||
'plugin:react-hooks/recommended', | ||
'plugin:@next/next/recommended', | ||
], | ||
plugins: ['import', 'react'], | ||
rules: { | ||
'import/no-anonymous-default-export': 'warn', | ||
'react/react-in-jsx-scope': 'off', | ||
}, | ||
parser: './parser.js', | ||
parserOptions: { | ||
requireConfigFile: false, | ||
sourceType: 'module', | ||
allowImportExportEverywhere: true, | ||
babelOptions: { | ||
presets: ['next/babel'], | ||
}, | ||
}, | ||
overrides: [ | ||
{ | ||
files: ['**/*.ts?(x)'], | ||
parser: '@typescript-eslint/parser', | ||
parserOptions: { | ||
sourceType: 'module', | ||
ecmaFeatures: { | ||
jsx: true, | ||
}, | ||
warnOnUnsupportedTypeScriptVersion: true, | ||
}, | ||
}, | ||
], | ||
settings: { | ||
react: { | ||
version: 'detect', | ||
}, | ||
'import/parsers': { | ||
[require.resolve('@typescript-eslint/parser')]: ['.ts', '.tsx', '.d.ts'], | ||
}, | ||
'import/resolver': { | ||
[require.resolve('eslint-import-resolver-node')]: { | ||
extensions: ['.js', '.jsx', '.ts', '.tsx'], | ||
}, | ||
}, | ||
}, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
{ | ||
"name": "eslint-config-next", | ||
"version": "10.1.4-canary.15", | ||
"description": "ESLint configuration used by NextJS.", | ||
"main": "index.js", | ||
"license": "MIT", | ||
"repository": { | ||
"url": "vercel/next.js", | ||
"directory": "packages/eslint-config-next" | ||
}, | ||
"dependencies": { | ||
"@rushstack/eslint-patch": "^1.0.6", | ||
"@next/eslint-plugin-next": "^10.1.3", | ||
"@typescript-eslint/parser": "^4.20.0", | ||
"eslint-import-resolver-node": "^0.3.4", | ||
"eslint-plugin-import": "^2.22.1", | ||
"eslint-plugin-react": "^7.23.1", | ||
"eslint-plugin-react-hooks": "^4.2.0" | ||
}, | ||
"peerDependencies": { | ||
"eslint": "^7.23.0", | ||
"next": ">=10.2.0", | ||
"typescript": ">=3.3.1" | ||
}, | ||
"peerDependenciesMeta": { | ||
"typescript": { | ||
"optional": true | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
const { | ||
parse, | ||
parseForESLint, | ||
} = require('next/dist/compiled/babel/eslint-parser') | ||
|
||
module.exports = { | ||
parse, | ||
parseForESLint, | ||
} |
Oops, something went wrong.