Skip to content

Commit 32f0c9a

Browse files
ykztsMichaelDeBoeytimneutkens
authored
Support ESLint v8 (#29865)
Co-authored-by: Michaël De Boey <[email protected]> Co-authored-by: Tim Neutkens <[email protected]>
1 parent a39a896 commit 32f0c9a

File tree

11 files changed

+366
-105
lines changed

11 files changed

+366
-105
lines changed

packages/create-next-app/create-app.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,7 @@ export async function createApp({
229229
/**
230230
* Default devDependencies.
231231
*/
232-
const devDependencies = ['eslint@7', 'eslint-config-next']
232+
const devDependencies = ['eslint', 'eslint-config-next']
233233
/**
234234
* TypeScript projects will have type definitions and other devDependencies.
235235
*/

packages/eslint-config-next/package.json

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,17 +10,17 @@
1010
},
1111
"dependencies": {
1212
"@next/eslint-plugin-next": "12.0.4",
13-
"@rushstack/eslint-patch": "^1.0.6",
14-
"@typescript-eslint/parser": "^4.20.0",
13+
"@rushstack/eslint-patch": "^1.0.8",
14+
"@typescript-eslint/parser": "^5.0.0",
1515
"eslint-import-resolver-node": "^0.3.4",
1616
"eslint-import-resolver-typescript": "^2.4.0",
17-
"eslint-plugin-import": "^2.22.1",
18-
"eslint-plugin-jsx-a11y": "^6.4.1",
19-
"eslint-plugin-react": "^7.23.1",
20-
"eslint-plugin-react-hooks": "^4.2.0"
17+
"eslint-plugin-import": "^2.25.2",
18+
"eslint-plugin-jsx-a11y": "^6.5.1",
19+
"eslint-plugin-react": "^7.27.0",
20+
"eslint-plugin-react-hooks": "^4.3.0"
2121
},
2222
"peerDependencies": {
23-
"eslint": "^7.23.0",
23+
"eslint": "^7.23.0 || ^8.0.0",
2424
"next": ">=10.2.0",
2525
"typescript": ">=3.3.1"
2626
},

packages/next/compiled/find-cache-dir/index.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/next/lib/eslint/runLintCheck.ts

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -94,8 +94,8 @@ async function lint(
9494
lintDuringBuild ? ' in order to run during builds:' : ':'
9595
} ${chalk.bold.cyan(
9696
(await isYarn(baseDir))
97-
? 'yarn add --dev eslint@"<8.0.0"' // TODO: Remove @"<8.0.0" when ESLint v8 is supported https://github.com/vercel/next.js/pull/29865
98-
: 'npm install --save-dev eslint@"<8.0.0"' // TODO: Remove @"<8.0.0" when ESLint v8 is supported https://github.com/vercel/next.js/pull/29865
97+
? 'yarn add --dev eslint'
98+
: 'npm install --save-dev eslint'
9999
)}`
100100
)
101101
return null
@@ -111,16 +111,7 @@ async function lint(
111111
'error'
112112
)} - Your project has an older version of ESLint installed${
113113
eslintVersion ? ' (' + eslintVersion + ')' : ''
114-
}. Please upgrade to ESLint version 7`
115-
} else if (semver.gte(eslintVersion, '8.0.0')) {
116-
// TODO: Remove this check when ESLint v8 is supported https://github.com/vercel/next.js/pull/29865
117-
return `${chalk.red('error')} - ESLint version ${
118-
eslintVersion ? eslintVersion : '8'
119-
} is not yet supported. Please downgrade to version 7 for the meantime: ${chalk.bold.cyan(
120-
(await isYarn(baseDir))
121-
? 'yarn remove eslint && yarn add --dev eslint@"<8.0.0"'
122-
: 'npm uninstall eslint && npm install --save-dev eslint@"<8.0.0"'
123-
)}`
114+
}. Please upgrade to ESLint version 7 or above`
124115
}
125116

126117
let options: any = {

test/integration/eslint/invalid-newer-eslint-version/.eslintrc

Lines changed: 0 additions & 4 deletions
This file was deleted.

test/integration/eslint/invalid-newer-eslint-version/node_modules/eslint/lib/api.js

Lines changed: 0 additions & 1 deletion
This file was deleted.

test/integration/eslint/invalid-newer-eslint-version/node_modules/eslint/package.json

Lines changed: 0 additions & 5 deletions
This file was deleted.

test/integration/eslint/invalid-newer-eslint-version/pages/index.js

Lines changed: 0 additions & 8 deletions
This file was deleted.

test/integration/eslint/test/index.test.js

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,6 @@ const dirInvalidOlderEslintVersion = join(
2525
__dirname,
2626
'../invalid-eslint-version'
2727
)
28-
const dirInvalidNewerEslintVersion = join(
29-
__dirname,
30-
'../invalid-newer-eslint-version'
31-
)
3228
const dirMaxWarnings = join(__dirname, '../max-warnings')
3329
const dirEmptyDirectory = join(__dirname, '../empty-directory')
3430
const dirEslintIgnore = join(__dirname, '../eslint-ignore')
@@ -115,24 +111,6 @@ describe('ESLint', () => {
115111
)
116112
})
117113

118-
// TODO: Remove this test when ESLint v8 is supported https://github.com/vercel/next.js/pull/29865
119-
test('invalid newer eslint version', async () => {
120-
const { stdout, stderr } = await nextBuild(
121-
dirInvalidNewerEslintVersion,
122-
[],
123-
{
124-
stdout: true,
125-
stderr: true,
126-
}
127-
)
128-
129-
const output = stdout + stderr
130-
console.log(output)
131-
expect(output).toContain(
132-
'ESLint version 8.0.1 is not yet supported. Please downgrade to version 7 for the meantime'
133-
)
134-
})
135-
136114
test('empty directories do not fail the build', async () => {
137115
const { stdout, stderr } = await nextBuild(dirEmptyDirectory, [], {
138116
stdout: true,

test/integration/telemetry/test/index.test.js

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -519,7 +519,10 @@ describe('Telemetry CLI', () => {
519519
})
520520

521521
it('emits telemetry for lint during build', async () => {
522-
await fs.writeFile(path.join(appDir, '.eslintrc'), `{ "extends": "next" }`)
522+
await fs.writeFile(
523+
path.join(appDir, '.eslintrc'),
524+
`{ "root": true, "extends": "next" }`
525+
)
523526
const { stderr } = await nextBuild(appDir, [], {
524527
stderr: true,
525528
env: { NEXT_TELEMETRY_DEBUG: 1 },
@@ -541,7 +544,10 @@ describe('Telemetry CLI', () => {
541544
})
542545

543546
it('emits telemetry for `next lint`', async () => {
544-
await fs.writeFile(path.join(appDir, '.eslintrc'), `{ "extends": "next" }`)
547+
await fs.writeFile(
548+
path.join(appDir, '.eslintrc'),
549+
`{ "root": true, "extends": "next" }`
550+
)
545551
const { stderr } = await nextLint(appDir, [], {
546552
stderr: true,
547553
env: { NEXT_TELEMETRY_DEBUG: 1 },

0 commit comments

Comments
 (0)