Skip to content

Commit

Permalink
fix: change peer dependencies to allow eslint v9 (#216)
Browse files Browse the repository at this point in the history
* Revert "fix: explicitly support ESLint 9.0.0 pre-releases (#200)"

This reverts commit a5eaa9c.

* build: tests on eslint v9

* chore: fix linting errors

* chore: fix eslint v9 tests
  • Loading branch information
aladdin-add authored Apr 7, 2024
1 parent d96976d commit 5e82d7f
Show file tree
Hide file tree
Showing 8 changed files with 55 additions and 53 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ jobs:
strategy:
matrix:
os: [ubuntu-latest, windows-latest, macOS-latest]
eslint: [8.x, "next"]
eslint: [8.x, "9.x"]
node: [18.x, 20.x]
include:
- os: ubuntu-latest
Expand Down
2 changes: 1 addition & 1 deletion lib/rules/file-extension-in-import.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ function getExistingExtensions(filePath) {
.readdirSync(directory)
.filter(filename => filename.startsWith(`${basename}.`))
.map(filename => path.extname(filename))
} catch (_error) {
} catch {
return []
}
}
Expand Down
2 changes: 1 addition & 1 deletion lib/rules/process-exit-as-throw.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ function safeRequire(...moduleNames) {
for (const moduleName of moduleNames) {
try {
return require(moduleName)
} catch (_err) {
} catch {
// Ignore.
}
}
Expand Down
2 changes: 1 addition & 1 deletion lib/util/get-package-json.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ function readPackageJson(dir) {
data.filePath = filePath
return data
}
} catch (_err) {
} catch {
// do nothing.
}

Expand Down
2 changes: 1 addition & 1 deletion lib/util/get-semver-range.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ module.exports = function getSemverRange(x) {
if (!ret) {
try {
ret = new Range(s)
} catch (_error) {
} catch {
// Ignore parsing error.
}
cache.set(s, ret)
Expand Down
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"configs/"
],
"peerDependencies": {
"eslint": "^8.23.0 || >=9.0.0-0"
"eslint": ">=8.23.0"
},
"dependencies": {
"@eslint-community/eslint-utils": "^4.4.0",
Expand All @@ -26,10 +26,10 @@
"semver": "^7.5.3"
},
"devDependencies": {
"@eslint/js": "^8.43.0",
"@eslint/js": "^9.0.0",
"@types/eslint": "^8.56.2",
"@typescript-eslint/parser": "^7.0.0",
"eslint": "^8",
"eslint": "^9.0.0",
"eslint-config-prettier": "^9.1.0",
"eslint-doc-generator": "^1.6.1",
"eslint-plugin-eslint-plugin": "^5.2.1",
Expand Down
14 changes: 7 additions & 7 deletions tests/lib/rules/no-unsupported-features/es-builtins.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,14 @@ function ignores(keyword) {
}

function runTests(patterns) {
for (const pattern of patterns) {
const ruleTester = new RuleTester({
languageOptions: {
ecmaVersion: "latest",
globals: globals.builtin,
},
})
const ruleTester = new RuleTester({
languageOptions: {
ecmaVersion: "latest",
globals: globals.builtin,
},
})

for (const pattern of patterns) {
const tests = {
valid: pattern.valid,
invalid: pattern.invalid,
Expand Down
78 changes: 40 additions & 38 deletions tests/lib/rules/no-unsupported-features/es-syntax.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,11 @@ function ignores(keyword) {
}

function runTests(patterns) {
for (const pattern of patterns) {
const ruleTester = new RuleTester({
languageOptions: { ecmaVersion: "latest", env: { node: false } },
})
const ruleTester = new RuleTester({
languageOptions: { ecmaVersion: "latest", env: { node: false } },
})

for (const pattern of patterns) {
const tests = {
valid: pattern.valid,
invalid: pattern.invalid,
Expand Down Expand Up @@ -492,40 +492,42 @@ runTests([
code: "(class { key(a = 0) {} })",
options: [{ version: "6.0.0" }],
},
{
code: "function f(a = 0) {}",
options: [{ version: "5.9.9", ignores: ["defaultParameters"] }],
},
{
code: "(function(a = 0) {})",
options: [{ version: "5.9.9", ignores: ["defaultParameters"] }],
},
{
code: "((a = 0) => a)",
options: [{ version: "5.9.9", ignores: ["defaultParameters"] }],
},
{
code: "({ key(a = 0) {} })",
options: [{ version: "5.9.9", ignores: ["defaultParameters"] }],
},
{
code: "class A { key(a = 0) {} }",
options: [
{
version: "5.9.9",
ignores: ["classes", "defaultParameters"],
},
],
},
{
code: "(class { key(a = 0) {} })",
options: [
{
version: "5.9.9",
ignores: ["classes", "defaultParameters"],
},
],
},

// detected duplicate tests by eslint v9
// {
// code: "function f(a = 0) {}",
// options: [{ version: "5.9.9", ignores: ["defaultParameters"] }],
// },
// {
// code: "(function(a = 0) {})",
// options: [{ version: "5.9.9", ignores: ["defaultParameters"] }],
// },
// {
// code: "((a = 0) => a)",
// options: [{ version: "5.9.9", ignores: ["defaultParameters"] }],
// },
// {
// code: "({ key(a = 0) {} })",
// options: [{ version: "5.9.9", ignores: ["defaultParameters"] }],
// },
// {
// code: "class A { key(a = 0) {} }",
// options: [
// {
// version: "5.9.9",
// ignores: ["classes", "defaultParameters"],
// },
// ],
// },
// {
// code: "(class { key(a = 0) {} })",
// options: [
// {
// version: "5.9.9",
// ignores: ["classes", "defaultParameters"],
// },
// ],
// },
],
invalid: [
{
Expand Down

0 comments on commit 5e82d7f

Please sign in to comment.