Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 72a6408

Browse files
feat: enable @typescript-eslint/recommended in create-next-app --typescript (vercel#52845)
Co-authored-by: eps1lon <[email protected]>
1 parent 689e4b8 commit 72a6408

File tree

16 files changed

+289
-57
lines changed

16 files changed

+289
-57
lines changed

docs/02-app/01-building-your-application/07-configuring/02-eslint.mdx

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,19 @@ The `next/core-web-vitals` rule set is enabled when `next lint` is run for the f
202202

203203
> The `next/core-web-vitals` entry point is automatically included for new applications built with [Create Next App](/docs/app/api-reference/create-next-app).
204204
205+
### TypeScript
206+
207+
In addition to the Next.js ESLint rules, `create-next-app --typescript` will also add TypeScript-specific lint rules with `next/typescript` to your config:
208+
209+
```json filename=".eslintrc.json"
210+
{
211+
"extends": ["next/core-web-vitals", "next/typescript"]
212+
}
213+
```
214+
215+
Those rules are based on [`plugin:@typescript-eslint/recommended`](https://typescript-eslint.io/linting/configs#recommended).
216+
See [typescript-eslint > Configs](https://typescript-eslint.io/linting/configs) for more details.
217+
205218
## Usage With Other Tools
206219

207220
### Prettier

examples/with-temporal/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@
2424
"@types/node-fetch": "^3.0.3",
2525
"@types/react": "^17.0.2",
2626
"@types/react-dom": "^17.0.1",
27-
"@typescript-eslint/eslint-plugin": "^5.3.0",
28-
"@typescript-eslint/parser": "^5.3.0",
27+
"@typescript-eslint/eslint-plugin": "^6.1.0",
28+
"@typescript-eslint/parser": "^6.1.0",
2929
"cross-env": "^7.0.3",
3030
"nodemon": "^2.0.12",
3131
"ts-node": "^10.2.1",
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
{
2-
"extends": "next/core-web-vitals"
2+
"extends": ["next/core-web-vitals", "next/typescript"]
33
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
{
2-
"extends": "next/core-web-vitals"
2+
"extends": ["next/core-web-vitals", "next/typescript"]
33
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
{
2-
"extends": "next/core-web-vitals"
2+
"extends": ["next/core-web-vitals", "next/typescript"]
33
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
{
2-
"extends": "next/core-web-vitals"
2+
"extends": ["next/core-web-vitals", "next/typescript"]
33
}

packages/eslint-config-next/index.js

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,13 @@ sortedPaths.push(...keptPaths)
3030

3131
const hookPropertyMap = new Map(
3232
[
33-
['eslint-plugin-import', 'eslint-plugin-import'],
34-
['eslint-plugin-react', 'eslint-plugin-react'],
35-
['eslint-plugin-jsx-a11y', 'eslint-plugin-jsx-a11y'],
36-
].map(([request, replacement]) => [
33+
'@typescript-eslint/eslint-plugin',
34+
'eslint-plugin-import',
35+
'eslint-plugin-react',
36+
'eslint-plugin-jsx-a11y',
37+
].map((request) => [
3738
request,
38-
require.resolve(replacement, { paths: sortedPaths }),
39+
require.resolve(request, { paths: sortedPaths }),
3940
])
4041
)
4142

@@ -96,10 +97,6 @@ module.exports = {
9697
parser: '@typescript-eslint/parser',
9798
parserOptions: {
9899
sourceType: 'module',
99-
ecmaFeatures: {
100-
jsx: true,
101-
},
102-
warnOnUnsupportedTypeScriptVersion: true,
103100
},
104101
},
105102
],

packages/eslint-config-next/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
"dependencies": {
1313
"@next/eslint-plugin-next": "15.0.0-canary.46",
1414
"@rushstack/eslint-patch": "^1.3.3",
15+
"@typescript-eslint/eslint-plugin": "^5.4.2 || ^6.0.0 || 7.0.0 - 7.2.0",
1516
"@typescript-eslint/parser": "^5.4.2 || ^6.0.0 || 7.0.0 - 7.2.0",
1617
"eslint-import-resolver-node": "^0.3.6",
1718
"eslint-import-resolver-typescript": "^3.5.2",
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
module.exports = {
2+
extends: ['plugin:@typescript-eslint/recommended'],
3+
}

packages/next/src/lib/constants.ts

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -79,26 +79,6 @@ export const SSG_FALLBACK_EXPORT_ERROR = `Pages with \`fallback\` enabled in \`g
7979

8080
export const ESLINT_DEFAULT_DIRS = ['app', 'pages', 'components', 'lib', 'src']
8181

82-
export const ESLINT_PROMPT_VALUES = [
83-
{
84-
title: 'Strict',
85-
recommended: true,
86-
config: {
87-
extends: 'next/core-web-vitals',
88-
},
89-
},
90-
{
91-
title: 'Base',
92-
config: {
93-
extends: 'next',
94-
},
95-
},
96-
{
97-
title: 'Cancel',
98-
config: null,
99-
},
100-
]
101-
10282
export const SERVER_RUNTIME: Record<string, ServerRuntime> = {
10383
edge: 'edge',
10484
experimentalEdge: 'experimental-edge',

0 commit comments

Comments
 (0)