Skip to content

Commit 598f57b

Browse files
authored
Update ESLint to v9, drop support for Node.js v16 (#2250)
1 parent 29025d9 commit 598f57b

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+615
-664
lines changed

.github/workflows/main.yml

+9-8
Original file line numberDiff line numberDiff line change
@@ -16,19 +16,20 @@ jobs:
1616
matrix:
1717
node-version:
1818
- 20
19-
- 16
19+
- 18
2020
os:
2121
- ubuntu-latest
2222
- windows-latest
23-
include:
24-
- os: ubuntu-latest
25-
node-version: 18
23+
# Even numbers of node-version
24+
# include:
25+
# - os: ubuntu-latest
26+
# node-version: 18
2627
steps:
2728
- uses: actions/checkout@v4
2829
- uses: actions/setup-node@v4
2930
with:
3031
node-version: ${{ matrix.node-version }}
31-
- run: npm install
32+
- run: npm install --legacy-peer-deps
3233
- run: npx ava
3334
lint-test:
3435
runs-on: ${{ matrix.os }}
@@ -43,7 +44,7 @@ jobs:
4344
with:
4445
# Locked due to the difference of `zlib.gzipSync()` between Node.js versions
4546
node-version: 20
46-
- run: npm install
47+
- run: npm install --legacy-peer-deps
4748
- run: npm run lint
4849
- run: npx del-cli test/snapshots --verbose
4950
# Force update snapshots, https://github.com/avajs/ava/discussions/2754
@@ -61,7 +62,7 @@ jobs:
6162
steps:
6263
- uses: actions/checkout@v4
6364
- uses: actions/setup-node@v4
64-
- run: npm install
65+
- run: npm install --legacy-peer-deps
6566
- run: npm run run-rules-on-codebase
6667
integration:
6768
name: Integration test (${{ matrix.group }})
@@ -84,5 +85,5 @@ jobs:
8485
steps:
8586
- uses: actions/checkout@v4
8687
- uses: actions/setup-node@v4
87-
- run: npm install
88+
- run: npm install --legacy-peer-deps
8889
- run: npm run integration -- --group ${{ matrix.group }}

package.json

+4-3
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@
5151
"dependencies": {
5252
"@babel/helper-validator-identifier": "^7.22.20",
5353
"@eslint-community/eslint-utils": "^4.4.0",
54-
"@eslint/eslintrc": "^2.1.4",
54+
"@eslint/eslintrc": "^3.0.0",
5555
"ci-info": "^4.0.0",
5656
"clean-regexp": "^1.0.0",
5757
"core-js-compat": "^3.34.0",
@@ -69,20 +69,21 @@
6969
"devDependencies": {
7070
"@babel/code-frame": "^7.23.5",
7171
"@babel/core": "^7.23.6",
72-
"@babel/eslint-parser": "^7.23.3",
72+
"@babel/eslint-parser": "^7.24.1",
7373
"@lubien/fixture-beta-package": "^1.0.0-beta.1",
7474
"@typescript-eslint/parser": "^7.5.0",
7575
"ava": "^6.0.1",
7676
"c8": "^8.0.1",
7777
"chalk": "^5.3.0",
7878
"enquirer": "^2.4.1",
79-
"eslint": "^8.56.0",
79+
"eslint": "^9.0.0",
8080
"eslint-ava-rule-tester": "^5.0.1",
8181
"eslint-doc-generator": "^1.7.0",
8282
"eslint-plugin-eslint-plugin": "^5.2.1",
8383
"eslint-plugin-internal-rules": "file:./scripts/internal-rules/",
8484
"eslint-remote-tester": "^3.0.1",
8585
"eslint-remote-tester-repositories": "^1.0.1",
86+
"espree": "^10.0.0",
8687
"execa": "^8.0.1",
8788
"listr": "^0.14.3",
8889
"lodash-es": "^4.17.21",

test/better-regex.mjs

+4-19
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
1-
import {createRequire} from 'node:module';
2-
import {getTester} from './utils/test.mjs';
1+
import {getTester, parsers} from './utils/test.mjs';
32

43
const {test} = getTester(import.meta);
5-
const require = createRequire(import.meta.url);
64

75
const MESSAGE_ID = 'better-regex';
86

@@ -220,21 +218,6 @@ test({
220218
errors: createError('[0-9]', '\\d'),
221219
output: 'const foo = new RegExp(\'\\\\d\', \'ig\')',
222220
},
223-
{
224-
code: 'const foo = new RegExp(/[0-9]/)',
225-
errors: createError('/[0-9]/', '/\\d/'),
226-
output: 'const foo = new RegExp(/\\d/)',
227-
},
228-
{
229-
code: 'const foo = new RegExp(/[0-9]/, \'ig\')',
230-
errors: createError('/[0-9]/', '/\\d/'),
231-
output: 'const foo = new RegExp(/\\d/, \'ig\')',
232-
},
233-
{
234-
code: 'const foo = new RegExp(/[0-9]/)',
235-
errors: createError('/[0-9]/', '/\\d/'),
236-
output: 'const foo = new RegExp(/\\d/)',
237-
},
238221
{
239222
code: 'const foo = new RegExp(/[0-9]/, \'ig\')',
240223
errors: createError('/[0-9]/', '/\\d/'),
@@ -310,7 +293,9 @@ test({
310293
message: 'Problem parsing /(/: \n\n/(/\n ^\nUnexpected token: "/" at 1:2.',
311294
},
312295
],
313-
parser: require.resolve('@typescript-eslint/parser'),
296+
languageOptions: {
297+
parser: parsers.typescript,
298+
},
314299
},
315300

316301
// Not fixable

test/catch-error-name.mjs

+8-7
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ function invalidTestCase(options) {
2929

3030
test({
3131
valid: [
32-
'try {} catch (error) {}',
3332
{
3433
code: 'try {} catch (err) {}',
3534
options: [{name: 'err'}],
@@ -900,12 +899,14 @@ test.typescript({
900899

901900
test.babel({
902901
testerOptions: {
903-
parserOptions: {
904-
babelOptions: {
905-
parserOpts: {
906-
plugins: [
907-
['decorators', {decoratorsBeforeExport: true}],
908-
],
902+
languageOptions: {
903+
parserOptions: {
904+
babelOptions: {
905+
parserOpts: {
906+
plugins: [
907+
['decorators', {decoratorsBeforeExport: true}],
908+
],
909+
},
909910
},
910911
},
911912
},

test/consistent-destructuring.mjs

+3-3
Original file line numberDiff line numberDiff line change
@@ -444,7 +444,7 @@ test({
444444
b
445445
}
446446
} = foo;
447-
console.log(foo.a.c);
447+
console.log(foo.a.c); // 2
448448
`,
449449
errors: [{
450450
message: 'Use destructured variables over properties.',
@@ -453,15 +453,15 @@ test({
453453
{
454454
code: outdent`
455455
const {a} = foo;
456-
console.log(foo.a);
456+
console.log(foo.a); // 2
457457
`,
458458
errors: [{
459459
message: 'Use destructured variables over properties.',
460460
suggestions: [{
461461
desc: 'Replace `foo.a` with destructured property `a`.',
462462
output: outdent`
463463
const {a} = foo;
464-
console.log(a);
464+
console.log(a); // 2
465465
`,
466466
}],
467467
}],

test/consistent-function-scoping.mjs

+7-11
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,11 @@ const createError = (functionNameWithKind, loc) => ({
1515

1616
test({
1717
testerOptions: {
18-
parserOptions: {
19-
ecmaFeatures: {
20-
jsx: true,
18+
languageOptions: {
19+
parserOptions: {
20+
ecmaFeatures: {
21+
jsx: true,
22+
},
2123
},
2224
},
2325
},
@@ -473,12 +475,6 @@ test({
473475
`,
474476
errors: [createError('arrow function \'doBar\'')],
475477
},
476-
{
477-
code: outdent`
478-
const doFoo = () => bar => bar;
479-
`,
480-
errors: [createError('arrow function')],
481-
},
482478
// `this`
483479
{
484480
code: outdent`
@@ -628,9 +624,9 @@ test({
628624
},
629625
// Actual message
630626
{
631-
code: 'function foo() { async function* bar() {} }',
627+
code: 'function foo() { async function* baz() {} }',
632628
errors: [{
633-
message: 'Move async generator function \'bar\' to the outer scope.',
629+
message: 'Move async generator function \'baz\' to the outer scope.',
634630
}],
635631
},
636632
// React Hooks

test/empty-brace-spaces.mjs

+15-14
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,12 @@ const cases = [
1616
'switch (foo) {case bar: {/* */}}',
1717
'switch (foo) {default: {/* */}}',
1818
'try {/* */} catch(foo){}',
19-
'try {} catch(foo){/* */}',
19+
'try {} catch(bar){/* */}',
2020
'try {} catch(foo){} finally {/* */}',
2121
'do {/* */} while (foo)',
2222
'while (foo){/* */}',
2323
'foo = () => {/* */}',
2424
'foo = function (){/* */}',
25-
'function foo(){/* */}',
2625
'foo = {/* */}',
2726
'class Foo {bar() {/* */}}',
2827
'foo = class {bar() {/* */}}',
@@ -49,11 +48,11 @@ test({
4948
].flatMap(body => allCases.map(code => code.replace(SPACES_PLACEHOLDER, body))),
5049
// Not empty
5150
...cases.map(code => code.replace(SPACES_PLACEHOLDER, 'unicorn')),
52-
...classBodyCases.map(code => code.replace(SPACES_PLACEHOLDER, 'bar() {}')),
51+
...classBodyCases.map(code => code.replace(SPACES_PLACEHOLDER, 'baz() {}')),
5352
// `with`
5453
{
5554
code: 'with (foo) {}',
56-
parserOptions: {ecmaVersion: 5, sourceType: 'script'},
55+
languageOptions: {ecmaVersion: 5, sourceType: 'script'},
5756
},
5857
// We don't check these cases
5958
...ignoredCases.map(code => code.replace(SPACES_PLACEHOLDER, ' ')),
@@ -75,7 +74,7 @@ test({
7574
code: 'with (foo) { }',
7675
output: 'with (foo) {}',
7776
errors: 1,
78-
parserOptions: {ecmaVersion: 5, sourceType: 'script'},
77+
languageOptions: {ecmaVersion: 5, sourceType: 'script'},
7978
},
8079
],
8180
});
@@ -94,9 +93,11 @@ test.snapshot({
9493
});
9594

9695
const enableBabelPlugins = plugins => ({
97-
babelOptions: {
98-
parserOpts: {
99-
plugins,
96+
parserOptions: {
97+
babelOptions: {
98+
parserOpts: {
99+
plugins,
100+
},
100101
},
101102
},
102103
});
@@ -110,19 +111,19 @@ test.babel({
110111
};
111112
`,
112113
output: 'const foo = do {};',
113-
parserOptions: enableBabelPlugin('doExpressions'),
114+
languageOptions: enableBabelPlugin('doExpressions'),
114115
errors: 1,
115116
},
116117
{
117118
code: 'const record = #{ };',
118119
output: 'const record = #{};',
119-
parserOptions: enableBabelPlugin(['recordAndTuple', {syntaxType: 'hash'}]),
120+
languageOptions: enableBabelPlugin(['recordAndTuple', {syntaxType: 'hash'}]),
120121
errors: 1,
121122
},
122123
{
123124
code: 'const record = {| |};',
124125
output: 'const record = {||};',
125-
parserOptions: enableBabelPlugin(['recordAndTuple', {syntaxType: 'bar'}]),
126+
languageOptions: enableBabelPlugin(['recordAndTuple', {syntaxType: 'bar'}]),
126127
errors: 1,
127128
},
128129
{
@@ -137,14 +138,14 @@ test.babel({
137138
static {}
138139
}
139140
`,
140-
parserOptions: enableBabelPlugin('classStaticBlock'),
141+
languageOptions: enableBabelPlugin('classStaticBlock'),
141142
errors: 1,
142143
},
143144
// ESLint can't parse this now
144145
// {
145146
// code: 'const foo = module { };',
146147
// output: 'const foo = module {};',
147-
// parserOptions: enableBabelPlugin('moduleBlocks'),
148+
// languageOptions: enableBabelPlugin('moduleBlocks'),
148149
// errors: 1
149150
// },
150151
{
@@ -153,7 +154,7 @@ test.babel({
153154
};
154155
`,
155156
output: 'const foo = async do {};',
156-
parserOptions: enableBabelPlugins(['doExpressions', 'asyncDoExpressions']),
157+
languageOptions: enableBabelPlugins(['doExpressions', 'asyncDoExpressions']),
157158
errors: 1,
158159
},
159160
],

0 commit comments

Comments
 (0)