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

feat: support ESLint v9 #206

Merged
merged 1 commit into from
Apr 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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