Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update ESLint to v9, drop support for Node.js v16 #2250

Merged
merged 90 commits into from Apr 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
90 commits
Select commit Hold shift + click to select a range
3b1d3a0
Update `eslint` to v9
fisker Jan 4, 2024
10b5977
Use `--legacy-peer-deps` temporarily
fisker Jan 4, 2024
ddf3c7c
Fix avatester
fisker Jan 5, 2024
6a50464
Fix snapshot test
fisker Jan 5, 2024
1faca31
Fix
fisker Jan 6, 2024
d2ea95b
Fix
fisker Jan 6, 2024
12dd4df
Fix
fisker Jan 6, 2024
9b8ef91
Fix
fisker Jan 6, 2024
e840a10
Fix
fisker Jan 6, 2024
69bc803
Fix
fisker Jan 6, 2024
bc7d746
Fix
fisker Jan 6, 2024
67a01cb
Rewrite
fisker Jan 6, 2024
851693b
Fix
fisker Jan 6, 2024
8fb05b7
Fix DEFAULT_LANGUAGE_OPTIONS
fisker Jan 6, 2024
e6fb4a5
Simplify
fisker Jan 6, 2024
770f320
Fix
fisker Jan 6, 2024
252a3e1
Fix
fisker Jan 6, 2024
a12f499
Fix
fisker Jan 6, 2024
e2aa76d
Fix
fisker Jan 6, 2024
007aa11
Fix
fisker Jan 6, 2024
30c9586
Fix
fisker Jan 6, 2024
1ebe8bd
Fix
fisker Jan 6, 2024
790ae0e
Fix `DEFAULT_LANGUAGE_OPTIONS`
fisker Jan 6, 2024
4dff4d8
Restore test
fisker Jan 6, 2024
51fb5bf
Fix
fisker Jan 6, 2024
b658454
9.0.0-alpha.1
fisker Jan 26, 2024
72506fc
Linting
fisker Jan 26, 2024
ecff1b8
^9.0.0-alpha.2
fisker Jan 27, 2024
76a0994
Fix lint config
fisker Jan 27, 2024
1dafebc
Fix languageOptions
fisker Jan 27, 2024
1b9092a
Fix `languageOptions`
fisker Jan 27, 2024
9efb519
Fix language options
fisker Jan 27, 2024
b239f8e
Fix languageOptions
fisker Jan 27, 2024
f761da0
Remove `defineParser`
fisker Jan 27, 2024
70a0b97
Add default parser
fisker Jan 27, 2024
bed75bb
Fix languageOptions
fisker Jan 27, 2024
f38c775
Linting
fisker Jan 27, 2024
ee77cc7
`9.0.0-beta.0`
fisker Feb 18, 2024
7ee0dda
Fix assertion
fisker Feb 18, 2024
104bcda
Fix assertion
fisker Feb 18, 2024
9b5e724
Fix assertion
fisker Feb 18, 2024
8c741b5
Fix assertion
fisker Feb 18, 2024
690a286
Fix assertion
fisker Feb 18, 2024
b0674af
Fix assertion
fisker Feb 18, 2024
7832063
Fix assertion
fisker Feb 18, 2024
af46387
Pass tests
fisker Feb 18, 2024
fb8ffb8
Linting
fisker Feb 18, 2024
9799368
Remove a TODO
fisker Feb 18, 2024
659d66f
Fix test
fisker Feb 18, 2024
c1c23d6
Fix test with filename
fisker Feb 18, 2024
32d07d6
Fix
fisker Feb 18, 2024
79e1001
Fix test on Node.js v18
fisker Feb 18, 2024
dff05d2
Fix
fisker Feb 18, 2024
5e745ec
Fix
fisker Feb 18, 2024
9653946
Linting
fisker Feb 18, 2024
546ac96
Run ESLint 8
fisker Feb 18, 2024
fdde80f
Move to "test" job
fisker Feb 18, 2024
05ccca4
Add to title
fisker Feb 18, 2024
d471f3f
format?
fisker Feb 18, 2024
2cd684a
Fix
fisker Feb 18, 2024
59405a8
Remove test on eslint@8
fisker Feb 18, 2024
60ee48e
Remove ` --legacy-peer-deps`
fisker Feb 18, 2024
0f6c8f8
Merge branch 'main' into eslint-9
fisker Feb 23, 2024
a401727
9.0.0
fisker Apr 6, 2024
b389a76
Merge branch 'main' into eslint-9
fisker Apr 6, 2024
368dc53
Update deps
fisker Apr 6, 2024
3a13a06
Revert "Remove ` --legacy-peer-deps`"
fisker Apr 6, 2024
012cd16
Linting
fisker Apr 6, 2024
1a24fcd
Deduplicate
fisker Apr 6, 2024
fe4b210
Deduplicate
fisker Apr 6, 2024
7857465
Fix
fisker Apr 6, 2024
f950506
Fix
fisker Apr 6, 2024
9889584
FIx
fisker Apr 6, 2024
2f35abb
Fix
fisker Apr 6, 2024
bbce146
Fix
fisker Apr 6, 2024
78645c4
Fix
fisker Apr 6, 2024
b7d76c9
Dedupe
fisker Apr 6, 2024
89d0422
Fix
fisker Apr 6, 2024
fbfd326
Dedupe
fisker Apr 6, 2024
96b1fa1
Fix
fisker Apr 6, 2024
e1c7f26
Fix
fisker Apr 6, 2024
b8bfa50
Dedupe
fisker Apr 6, 2024
2af5a36
Dedupe
fisker Apr 6, 2024
acb5ccd
Dedupe
fisker Apr 6, 2024
5aed918
Fix
fisker Apr 6, 2024
5e77ac9
Dedupe
fisker Apr 6, 2024
6608d8a
Fix
fisker Apr 6, 2024
9f64fee
Merge branch 'main' into eslint-9
fisker Apr 8, 2024
92a37a6
Fix snapshot
fisker Apr 8, 2024
a5f980a
Merge branch 'main' into eslint-9
fisker Apr 9, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
17 changes: 9 additions & 8 deletions .github/workflows/main.yml
Expand Up @@ -16,19 +16,20 @@ jobs:
matrix:
node-version:
- 20
- 16
- 18
os:
- ubuntu-latest
- windows-latest
include:
- os: ubuntu-latest
node-version: 18
# Even numbers of node-version
# include:
# - os: ubuntu-latest
# node-version: 18
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
- run: npm install
- run: npm install --legacy-peer-deps
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This PR is ready for review, but we should either keep this flag or wait for babel/babel#16220

- run: npx ava
lint-test:
runs-on: ${{ matrix.os }}
Expand All @@ -43,7 +44,7 @@ jobs:
with:
# Locked due to the difference of `zlib.gzipSync()` between Node.js versions
node-version: 20
- run: npm install
- run: npm install --legacy-peer-deps
- run: npm run lint
- run: npx del-cli test/snapshots --verbose
# Force update snapshots, https://github.com/avajs/ava/discussions/2754
Expand All @@ -61,7 +62,7 @@ jobs:
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
- run: npm install
- run: npm install --legacy-peer-deps
- run: npm run run-rules-on-codebase
integration:
name: Integration test (${{ matrix.group }})
Expand All @@ -84,5 +85,5 @@ jobs:
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
- run: npm install
- run: npm install --legacy-peer-deps
- run: npm run integration -- --group ${{ matrix.group }}
7 changes: 4 additions & 3 deletions package.json
Expand Up @@ -51,7 +51,7 @@
"dependencies": {
"@babel/helper-validator-identifier": "^7.22.20",
"@eslint-community/eslint-utils": "^4.4.0",
"@eslint/eslintrc": "^2.1.4",
"@eslint/eslintrc": "^3.0.0",
"ci-info": "^4.0.0",
"clean-regexp": "^1.0.0",
"core-js-compat": "^3.34.0",
Expand All @@ -69,20 +69,21 @@
"devDependencies": {
"@babel/code-frame": "^7.23.5",
"@babel/core": "^7.23.6",
"@babel/eslint-parser": "^7.23.3",
"@babel/eslint-parser": "^7.24.1",
"@lubien/fixture-beta-package": "^1.0.0-beta.1",
"@typescript-eslint/parser": "^7.5.0",
"ava": "^6.0.1",
"c8": "^8.0.1",
"chalk": "^5.3.0",
"enquirer": "^2.4.1",
"eslint": "^8.56.0",
"eslint": "^9.0.0",
"eslint-ava-rule-tester": "^5.0.1",
"eslint-doc-generator": "^1.7.0",
"eslint-plugin-eslint-plugin": "^5.2.1",
"eslint-plugin-internal-rules": "file:./scripts/internal-rules/",
"eslint-remote-tester": "^3.0.1",
"eslint-remote-tester-repositories": "^1.0.1",
"espree": "^10.0.0",
"execa": "^8.0.1",
"listr": "^0.14.3",
"lodash-es": "^4.17.21",
Expand Down
23 changes: 4 additions & 19 deletions test/better-regex.mjs
@@ -1,8 +1,6 @@
import {createRequire} from 'node:module';
import {getTester} from './utils/test.mjs';
import {getTester, parsers} from './utils/test.mjs';

const {test} = getTester(import.meta);
const require = createRequire(import.meta.url);

const MESSAGE_ID = 'better-regex';

Expand Down Expand Up @@ -220,21 +218,6 @@ test({
errors: createError('[0-9]', '\\d'),
output: 'const foo = new RegExp(\'\\\\d\', \'ig\')',
},
{
code: 'const foo = new RegExp(/[0-9]/)',
errors: createError('/[0-9]/', '/\\d/'),
output: 'const foo = new RegExp(/\\d/)',
},
{
code: 'const foo = new RegExp(/[0-9]/, \'ig\')',
errors: createError('/[0-9]/', '/\\d/'),
output: 'const foo = new RegExp(/\\d/, \'ig\')',
},
{
code: 'const foo = new RegExp(/[0-9]/)',
errors: createError('/[0-9]/', '/\\d/'),
output: 'const foo = new RegExp(/\\d/)',
},
{
code: 'const foo = new RegExp(/[0-9]/, \'ig\')',
errors: createError('/[0-9]/', '/\\d/'),
Expand Down Expand Up @@ -310,7 +293,9 @@ test({
message: 'Problem parsing /(/: \n\n/(/\n ^\nUnexpected token: "/" at 1:2.',
},
],
parser: require.resolve('@typescript-eslint/parser'),
languageOptions: {
parser: parsers.typescript,
},
},

// Not fixable
Expand Down
15 changes: 8 additions & 7 deletions test/catch-error-name.mjs
Expand Up @@ -29,7 +29,6 @@ function invalidTestCase(options) {

test({
valid: [
'try {} catch (error) {}',
{
code: 'try {} catch (err) {}',
options: [{name: 'err'}],
Expand Down Expand Up @@ -900,12 +899,14 @@ test.typescript({

test.babel({
testerOptions: {
parserOptions: {
babelOptions: {
parserOpts: {
plugins: [
['decorators', {decoratorsBeforeExport: true}],
],
languageOptions: {
parserOptions: {
babelOptions: {
parserOpts: {
plugins: [
['decorators', {decoratorsBeforeExport: true}],
],
},
},
},
},
Expand Down
6 changes: 3 additions & 3 deletions test/consistent-destructuring.mjs
Expand Up @@ -444,7 +444,7 @@ test({
b
}
} = foo;
console.log(foo.a.c);
console.log(foo.a.c); // 2
`,
errors: [{
message: 'Use destructured variables over properties.',
Expand All @@ -453,15 +453,15 @@ test({
{
code: outdent`
const {a} = foo;
console.log(foo.a);
console.log(foo.a); // 2
`,
errors: [{
message: 'Use destructured variables over properties.',
suggestions: [{
desc: 'Replace `foo.a` with destructured property `a`.',
output: outdent`
const {a} = foo;
console.log(a);
console.log(a); // 2
`,
}],
}],
Expand Down
18 changes: 7 additions & 11 deletions test/consistent-function-scoping.mjs
Expand Up @@ -15,9 +15,11 @@ const createError = (functionNameWithKind, loc) => ({

test({
testerOptions: {
parserOptions: {
ecmaFeatures: {
jsx: true,
languageOptions: {
parserOptions: {
ecmaFeatures: {
jsx: true,
},
},
},
},
Expand Down Expand Up @@ -473,12 +475,6 @@ test({
`,
errors: [createError('arrow function \'doBar\'')],
},
{
code: outdent`
const doFoo = () => bar => bar;
`,
errors: [createError('arrow function')],
},
// `this`
{
code: outdent`
Expand Down Expand Up @@ -628,9 +624,9 @@ test({
},
// Actual message
{
code: 'function foo() { async function* bar() {} }',
code: 'function foo() { async function* baz() {} }',
errors: [{
message: 'Move async generator function \'bar\' to the outer scope.',
message: 'Move async generator function \'baz\' to the outer scope.',
}],
},
// React Hooks
Expand Down
29 changes: 15 additions & 14 deletions test/empty-brace-spaces.mjs
Expand Up @@ -16,13 +16,12 @@ const cases = [
'switch (foo) {case bar: {/* */}}',
'switch (foo) {default: {/* */}}',
'try {/* */} catch(foo){}',
'try {} catch(foo){/* */}',
'try {} catch(bar){/* */}',
'try {} catch(foo){} finally {/* */}',
'do {/* */} while (foo)',
'while (foo){/* */}',
'foo = () => {/* */}',
'foo = function (){/* */}',
'function foo(){/* */}',
'foo = {/* */}',
'class Foo {bar() {/* */}}',
'foo = class {bar() {/* */}}',
Expand All @@ -49,11 +48,11 @@ test({
].flatMap(body => allCases.map(code => code.replace(SPACES_PLACEHOLDER, body))),
// Not empty
...cases.map(code => code.replace(SPACES_PLACEHOLDER, 'unicorn')),
...classBodyCases.map(code => code.replace(SPACES_PLACEHOLDER, 'bar() {}')),
...classBodyCases.map(code => code.replace(SPACES_PLACEHOLDER, 'baz() {}')),
// `with`
{
code: 'with (foo) {}',
parserOptions: {ecmaVersion: 5, sourceType: 'script'},
languageOptions: {ecmaVersion: 5, sourceType: 'script'},
},
// We don't check these cases
...ignoredCases.map(code => code.replace(SPACES_PLACEHOLDER, ' ')),
Expand All @@ -75,7 +74,7 @@ test({
code: 'with (foo) { }',
output: 'with (foo) {}',
errors: 1,
parserOptions: {ecmaVersion: 5, sourceType: 'script'},
languageOptions: {ecmaVersion: 5, sourceType: 'script'},
},
],
});
Expand All @@ -94,9 +93,11 @@ test.snapshot({
});

const enableBabelPlugins = plugins => ({
babelOptions: {
parserOpts: {
plugins,
parserOptions: {
babelOptions: {
parserOpts: {
plugins,
},
},
},
});
Expand All @@ -110,19 +111,19 @@ test.babel({
};
`,
output: 'const foo = do {};',
parserOptions: enableBabelPlugin('doExpressions'),
languageOptions: enableBabelPlugin('doExpressions'),
errors: 1,
},
{
code: 'const record = #{ };',
output: 'const record = #{};',
parserOptions: enableBabelPlugin(['recordAndTuple', {syntaxType: 'hash'}]),
languageOptions: enableBabelPlugin(['recordAndTuple', {syntaxType: 'hash'}]),
errors: 1,
},
{
code: 'const record = {| |};',
output: 'const record = {||};',
parserOptions: enableBabelPlugin(['recordAndTuple', {syntaxType: 'bar'}]),
languageOptions: enableBabelPlugin(['recordAndTuple', {syntaxType: 'bar'}]),
errors: 1,
},
{
Expand All @@ -137,14 +138,14 @@ test.babel({
static {}
}
`,
parserOptions: enableBabelPlugin('classStaticBlock'),
languageOptions: enableBabelPlugin('classStaticBlock'),
errors: 1,
},
// ESLint can't parse this now
// {
// code: 'const foo = module { };',
// output: 'const foo = module {};',
// parserOptions: enableBabelPlugin('moduleBlocks'),
// languageOptions: enableBabelPlugin('moduleBlocks'),
// errors: 1
// },
{
Expand All @@ -153,7 +154,7 @@ test.babel({
};
`,
output: 'const foo = async do {};',
parserOptions: enableBabelPlugins(['doExpressions', 'asyncDoExpressions']),
languageOptions: enableBabelPlugins(['doExpressions', 'asyncDoExpressions']),
errors: 1,
},
],
Expand Down