Skip to content

Commit 729d71e

Browse files
committed
build: update to eslint v9
This change adds support for eslint v9. All three example projects have been updated to use the latest eslint, and the root package's dev and peer deps have been updated. In order to make this work with both v9 and older versions, I had to update the parser options helper to adjust the config passed into the `RuleTester`. It was also necessary update jest to a newer version, in order to resolve eslint's use of `node:fs/promises`. Note: the removed test cases are exact duplicates of other tests. v9 fails tests when its determined to be an exact duplicate.
1 parent 05a5e49 commit 729d71e

22 files changed

+174
-87
lines changed

.babelrc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@
88
},
99
"transformRuntime": false
1010
}
11-
]
11+
],
12+
"@babel/preset-env"
1213
],
1314
"plugins": [
1415
"@babel/plugin-transform-flow-strip-types",

.flowconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,6 @@
33
<PROJECT_ROOT>/lib/.*
44
<PROJECT_ROOT>/docs/.*
55
<PROJECT_ROOT>/reports/.*
6+
<PROJECT_ROOT>/examples/.*
67
[options]
78
suppress_type=$FlowFixMe

.github/workflows/node-4+.yml

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,26 @@ jobs:
2525
matrix:
2626
node-version: ${{ fromJson(needs.matrix.outputs.latest) }}
2727
eslint:
28+
- 9
2829
- 8
2930
- 7
3031
- 6
3132
- 5
3233
- 4
3334
- 3
3435
exclude:
36+
- node-version: 16
37+
eslint: 9
38+
- node-version: 15
39+
eslint: 9
40+
- node-version: 13
41+
eslint: 9
42+
- node-version: 11
43+
eslint: 9
44+
- node-version: 10
45+
eslint: 9
46+
- node-version: 9
47+
eslint: 9
3548
- node-version: 15
3649
eslint: 8
3750
- node-version: 13
@@ -90,7 +103,7 @@ jobs:
90103
steps:
91104
- uses: actions/checkout@v4
92105
with:
93-
fetch-depth: 0
106+
fetch-depth: 0
94107
- uses: ljharb/actions/node/install@main
95108
name: 'nvm install ${{ matrix.node-version }} && npm install'
96109
env:
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
import assert from 'assert';
2+
3+
export default assert;
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
import fs from 'fs/promises';
2+
3+
export default fs;
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
import fs from 'fs';
2+
3+
export default fs;
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
import path from 'path';
2+
3+
export default path;
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
import url from 'url';
2+
3+
export default url;
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
import util from 'util';
2+
3+
export default util;
Lines changed: 40 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,53 @@
1+
import { version as eslintVersion } from 'eslint/package.json';
2+
import semver from 'semver';
3+
4+
const usingLegacy = semver.major(eslintVersion) < 9;
5+
16
const defaultParserOptions = {
2-
ecmaVersion: 2018,
37
ecmaFeatures: {
48
experimentalObjectRestSpread: true,
59
jsx: true,
610
},
711
};
812

13+
const defaultLegacyParserOptions = {
14+
...defaultParserOptions,
15+
ecmaVersion: 2018,
16+
};
17+
18+
const defaultLanguageOptions = {
19+
ecmaVersion: 'latest',
20+
parserOptions: {
21+
...defaultParserOptions,
22+
},
23+
};
24+
925
export default function parserOptionsMapper({
1026
code,
1127
errors,
1228
options = [],
13-
parserOptions = {},
14-
settings,
29+
languageOptions = {},
30+
settings = {},
1531
}) {
16-
return {
17-
code,
18-
errors,
19-
options,
20-
parserOptions: {
21-
...defaultParserOptions,
22-
...parserOptions,
23-
},
24-
settings,
25-
};
32+
return usingLegacy
33+
? {
34+
code,
35+
errors,
36+
options,
37+
parserOptions: {
38+
...defaultLegacyParserOptions,
39+
...languageOptions,
40+
},
41+
settings,
42+
}
43+
: {
44+
code,
45+
errors,
46+
options,
47+
languageOptions: {
48+
...defaultLanguageOptions,
49+
...languageOptions,
50+
},
51+
settings,
52+
};
2653
}

0 commit comments

Comments
 (0)