diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index c1f72fe..4bd58a0 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -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 diff --git a/package.json b/package.json index d18132b..59fb429 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/tests/lib/illegal-eslint-disable-line.js b/tests/lib/illegal-eslint-disable-line.js index 9abe5f3..b05a6dd 100644 --- a/tests/lib/illegal-eslint-disable-line.js +++ b/tests/lib/illegal-eslint-disable-line.js @@ -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 diff --git a/tests/lib/rules/no-restricted-disable.js b/tests/lib/rules/no-restricted-disable.js index e24370d..569fed7 100644 --- a/tests/lib/rules/no-restricted-disable.js +++ b/tests/lib/rules/no-restricted-disable.js @@ -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: [ diff --git a/tests/lib/rules/no-unused-disable.js b/tests/lib/rules/no-unused-disable.js index d62fbe2..ebd0d1e 100644 --- a/tests/lib/rules/no-unused-disable.js +++ b/tests/lib/rules/no-unused-disable.js @@ -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