Skip to content

Commit d51bb4d

Browse files
authored
feat: support ESLint v9 (#206)
1 parent 73811aa commit d51bb4d

File tree

5 files changed

+35
-7
lines changed

5 files changed

+35
-7
lines changed

.github/workflows/ci.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,10 @@ jobs:
5454
- os: macos-latest
5555
eslint: 8
5656
node: 18
57+
# On ESLint 9
58+
- eslint: 9
59+
node: 18
60+
os: ubuntu-latest
5761
# On old ESLint versions
5862
- eslint: 7
5963
node: 18

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
"lib"
1111
],
1212
"peerDependencies": {
13-
"eslint": "^6.0.0 || ^7.0.0 || ^8.0.0"
13+
"eslint": "^6.0.0 || ^7.0.0 || ^8.0.0 || ^9.0.0"
1414
},
1515
"dependencies": {
1616
"escape-string-regexp": "^4.0.0",

tests/lib/illegal-eslint-disable-line.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,11 @@ function runESLint(code) {
2828
"--format",
2929
"json",
3030
],
31-
{ stdio: ["pipe", "pipe", "inherit"] }
31+
{
32+
stdio: ["pipe", "pipe", "inherit"],
33+
// eslint-disable-next-line no-process-env, @eslint-community/mysticatea/node/no-process-env
34+
env: { ...process.env, ESLINT_USE_FLAT_CONFIG: "false" },
35+
}
3236
)
3337
const chunks = []
3438
let totalLength = 0

tests/lib/rules/no-restricted-disable.js

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,27 @@
77
const semver = require("semver")
88
const { Linter, RuleTester } = require("eslint")
99
const rule = require("../../../lib/rules/no-restricted-disable")
10-
const coreRules = new Linter().getRules()
11-
const tester = new RuleTester()
10+
const coreRules = new Linter({ configType: "eslintrc" }).getRules()
11+
let tester = null
1212

13-
tester.defineRule("foo/no-undef", coreRules.get("no-undef"))
14-
tester.defineRule("foo/no-redeclare", coreRules.get("no-redeclare"))
13+
if (typeof RuleTester.prototype.defineRule === "function") {
14+
// ESLint < 9
15+
tester = new RuleTester()
16+
tester.defineRule("foo/no-undef", coreRules.get("no-undef"))
17+
tester.defineRule("foo/no-redeclare", coreRules.get("no-redeclare"))
18+
} else {
19+
// ESLint 9
20+
tester = new RuleTester({
21+
plugins: {
22+
foo: {
23+
rules: {
24+
"no-undef": coreRules.get("no-undef"),
25+
"no-redeclare": coreRules.get("no-redeclare"),
26+
},
27+
},
28+
},
29+
})
30+
}
1531

1632
tester.run("no-restricted-disable", rule, {
1733
valid: [

tests/lib/rules/no-unused-disable.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,11 @@ function runESLint(code, reportUnusedDisableDirectives = false) {
4747
? ["--report-unused-disable-directives"]
4848
: []),
4949
],
50-
{ stdio: ["pipe", "pipe", "inherit"] }
50+
{
51+
stdio: ["pipe", "pipe", "inherit"],
52+
// eslint-disable-next-line no-process-env, @eslint-community/mysticatea/node/no-process-env
53+
env: { ...process.env, ESLINT_USE_FLAT_CONFIG: "false" },
54+
}
5155
)
5256
const chunks = []
5357
let totalLength = 0

0 commit comments

Comments
 (0)