Skip to content

Commit

Permalink
feat: support ESLint v9
Browse files Browse the repository at this point in the history
  • Loading branch information
fasttime committed Apr 7, 2024
1 parent 73811aa commit 301104e
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 7 deletions.
4 changes: 4 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,10 @@ jobs:
- os: macos-latest
eslint: 8
node: 18
# On ESLint 9
- eslint: 9
node: 18
os: ubuntu-latest
# On old ESLint versions
- eslint: 7
node: 18
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"lib"
],
"peerDependencies": {
"eslint": "^6.0.0 || ^7.0.0 || ^8.0.0"
"eslint": "^6.0.0 || ^7.0.0 || ^8.0.0 || ^9.0.0"
},
"dependencies": {
"escape-string-regexp": "^4.0.0",
Expand Down
6 changes: 5 additions & 1 deletion tests/lib/illegal-eslint-disable-line.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,11 @@ function runESLint(code) {
"--format",
"json",
],
{ stdio: ["pipe", "pipe", "inherit"] }
{
stdio: ["pipe", "pipe", "inherit"],
// eslint-disable-next-line no-process-env, @eslint-community/mysticatea/node/no-process-env
env: { ...process.env, ESLINT_USE_FLAT_CONFIG: "false" },
}
)
const chunks = []
let totalLength = 0
Expand Down
24 changes: 20 additions & 4 deletions tests/lib/rules/no-restricted-disable.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,27 @@
const semver = require("semver")
const { Linter, RuleTester } = require("eslint")
const rule = require("../../../lib/rules/no-restricted-disable")
const coreRules = new Linter().getRules()
const tester = new RuleTester()
const coreRules = new Linter({ configType: "eslintrc" }).getRules()
let tester = null

tester.defineRule("foo/no-undef", coreRules.get("no-undef"))
tester.defineRule("foo/no-redeclare", coreRules.get("no-redeclare"))
if (typeof RuleTester.prototype.defineRule === "function") {
// ESLint < 9
tester = new RuleTester()
tester.defineRule("foo/no-undef", coreRules.get("no-undef"))
tester.defineRule("foo/no-redeclare", coreRules.get("no-redeclare"))
} else {
// ESLint 9
tester = new RuleTester({
plugins: {
foo: {
rules: {
"no-undef": coreRules.get("no-undef"),
"no-redeclare": coreRules.get("no-redeclare"),
},
},
},
})
}

tester.run("no-restricted-disable", rule, {
valid: [
Expand Down
6 changes: 5 additions & 1 deletion tests/lib/rules/no-unused-disable.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,11 @@ function runESLint(code, reportUnusedDisableDirectives = false) {
? ["--report-unused-disable-directives"]
: []),
],
{ stdio: ["pipe", "pipe", "inherit"] }
{
stdio: ["pipe", "pipe", "inherit"],
// eslint-disable-next-line no-process-env, @eslint-community/mysticatea/node/no-process-env
env: { ...process.env, ESLINT_USE_FLAT_CONFIG: "false" },
}
)
const chunks = []
let totalLength = 0
Expand Down

0 comments on commit 301104e

Please sign in to comment.