Skip to content

Commit 90f2b3e

Browse files
committed
feat: support ESLint 8.x
1 parent a38dc5d commit 90f2b3e

File tree

6 files changed

+66
-20
lines changed

6 files changed

+66
-20
lines changed

.github/workflows/CI.yml

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ jobs:
1818
name: ⬣ Lint (ESLint@${{ matrix.eslint }})
1919
strategy:
2020
matrix:
21-
eslint: [6, 7]
21+
eslint: [6, 7, 8]
2222
runs-on: ubuntu-latest
2323
steps:
2424
- name: 🛑 Cancel Previous Runs
@@ -47,18 +47,21 @@ jobs:
4747
matrix.os }})
4848
strategy:
4949
matrix:
50-
eslint: [7]
50+
eslint: [8]
5151
node: [12.22.0, 12, 14.17.0, 14, 16, 18]
5252
os: [ubuntu-latest]
5353
include:
5454
# On other platforms
5555
- os: windows-latest
56-
eslint: 7
56+
eslint: 8
5757
node: 18
5858
- os: macos-latest
59-
eslint: 7
59+
eslint: 8
6060
node: 18
6161
# On old ESLint versions
62+
- eslint: 7
63+
node: 18
64+
os: ubuntu-latest
6265
- eslint: 6
6366
node: 18
6467
os: ubuntu-latest

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ npm install --save-dev eslint @eslint-community/eslint-plugin-mysticatea
1717
### Requirements
1818

1919
- Node.js `^12.22.0 || ^14.17.0 || >=16.0.0` or newer versions.
20-
- ESLint `^6.6.0 || ^7.0.0` or newer versions.
20+
- ESLint `^6.6.0 || ^7.0.0 || ^8.0.0` or newer versions.
2121

2222
## 📖 Usage
2323

lib/configs/_base.js

Lines changed: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
const { Linter } = require("eslint")
88

99
const isESLint7 = Linter.version.startsWith("7")
10+
const isESLint8 = Linter.version.startsWith("8")
1011

1112
/** @type {import('eslint').Linter.Config} */
1213
module.exports = {
@@ -32,7 +33,7 @@ module.exports = {
3233
"consistent-return": "error",
3334
curly: "error",
3435
"default-case": "error",
35-
...(isESLint7 ? { "default-case-last": "off" } : {}), // TODO: enable once we drop ESLint v6 support
36+
...(isESLint7 || isESLint8 ? { "default-case-last": "off" } : {}), // TODO: enable once we drop ESLint v6 support
3637
"default-param-last": "error",
3738
"dot-notation": "error",
3839
eqeqeq: ["error", "always", { null: "ignore" }],
@@ -43,6 +44,7 @@ module.exports = {
4344
"init-declarations": "error",
4445
"linebreak-style": ["error", "unix"],
4546
"lines-between-class-members": "error",
47+
...(isESLint8 ? { "logical-assignment-operators": "off" } : {}), // TODO: enable once we drop ESLint v7 support
4648
"max-statements-per-line": ["error", { max: 1 }],
4749
"multiline-comment-style": ["error", "separate-lines"],
4850
"new-cap": "error",
@@ -53,6 +55,7 @@ module.exports = {
5355
"no-case-declarations": "error",
5456
"no-compare-neg-zero": "error",
5557
"no-cond-assign": "error",
58+
...(isESLint8 ? { "no-constant-binary-expression": "off" } : {}), // TODO: enable once we drop ESLint v7 support
5659
"no-constant-condition": "error",
5760
"no-constructor-return": "error",
5861
"no-control-regex": "error",
@@ -68,6 +71,7 @@ module.exports = {
6871
"no-empty-character-class": "error",
6972
"no-empty-function": "error",
7073
"no-empty-pattern": "error",
74+
...(isESLint8 ? { "no-empty-static-block": "off" } : {}), // TODO: enable once we drop ESLint v7 support
7175
"no-eval": "error",
7276
"no-ex-assign": "error",
7377
"no-extend-native": "error",
@@ -98,7 +102,7 @@ module.exports = {
98102
"no-lone-blocks": "error",
99103
"no-lonely-if": "error",
100104
"no-loop-func": "error",
101-
...(isESLint7 ? { "no-loss-of-precision": "off" } : {}), // TODO: enable once we drop ESLint v6 support
105+
...(isESLint7 || isESLint8 ? { "no-loss-of-precision": "off" } : {}), // TODO: enable once we drop ESLint v6 support
102106
"no-misleading-character-class": "error",
103107
"no-mixed-operators": [
104108
"error",
@@ -110,17 +114,22 @@ module.exports = {
110114
},
111115
],
112116
"no-new": "error",
117+
...(isESLint8 ? { "no-new-native-nonconstructor": "off" } : {}), // TODO: enable once we drop ESLint v7 support
113118
"no-new-object": "error",
114119
"no-new-require": "error",
115120
"no-new-wrappers": "error",
116-
...(isESLint7 ? { "no-nonoctal-decimal-escape": "off" } : {}), // TODO: enable once we drop ESLint v6 support
121+
...(isESLint7 || isESLint8
122+
? { "no-nonoctal-decimal-escape": "off" }
123+
: {}), // TODO: enable once we drop ESLint v6 support
117124
"no-obj-calls": "error",
118125
"no-octal": "error",
119126
"no-octal-escape": "error",
120127
"no-param-reassign": ["error", { props: false }],
121128
"no-process-env": "error",
122129
"no-process-exit": "error",
123-
...(isESLint7 ? { "no-promise-executor-return": "off" } : {}), // TODO: enable once we drop ESLint v6 support
130+
...(isESLint7 || isESLint8
131+
? { "no-promise-executor-return": "off" }
132+
: {}), // TODO: enable once we drop ESLint v6 support
124133
"no-prototype-builtins": "error",
125134
"no-redeclare": ["error", { builtinGlobals: true }],
126135
"no-regex-spaces": "error",
@@ -151,12 +160,15 @@ module.exports = {
151160
"no-unmodified-loop-condition": "error",
152161
"no-unneeded-ternary": "error",
153162
"no-unreachable": "error",
154-
...(isESLint7 ? { "no-unreachable-loop": "off" } : {}), // TODO: enable once we drop ESLint v6 support
163+
...(isESLint7 || isESLint8 ? { "no-unreachable-loop": "off" } : {}), // TODO: enable once we drop ESLint v6 support
155164
"no-unsafe-finally": "error",
156165
"no-unsafe-negation": ["error", { enforceForOrderingRelations: true }],
157-
...(isESLint7 ? { "no-unsafe-optional-chaining": "off" } : {}), // TODO: enable once we drop ESLint v6 support
166+
...(isESLint7 || isESLint8
167+
? { "no-unsafe-optional-chaining": "off" }
168+
: {}), // TODO: enable once we drop ESLint v6 support
158169
"no-unused-expressions": "error",
159170
"no-unused-labels": "error",
171+
...(isESLint8 ? { "no-unused-private-class-members": "off" } : {}), // TODO: enable once we drop ESLint v7 support
160172
"no-unused-vars": [
161173
"error",
162174
{
@@ -168,7 +180,9 @@ module.exports = {
168180
},
169181
],
170182
"no-use-before-define": ["error", "nofunc"],
171-
...(isESLint7 ? { "no-useless-backreference": "off" } : {}), // TODO: enable once we drop ESLint v6 support
183+
...(isESLint7 || isESLint8
184+
? { "no-useless-backreference": "off" }
185+
: {}), // TODO: enable once we drop ESLint v6 support
172186
"no-useless-call": "error",
173187
"no-useless-catch": "error",
174188
"no-useless-concat": "error",
@@ -190,6 +204,7 @@ module.exports = {
190204
{ blankLine: "always", next: "*", prev: "function" },
191205
],
192206
"prefer-exponentiation-operator": "error",
207+
...(isESLint8 ? { "prefer-object-has-own": "off" } : {}), // TODO: enable once we drop ESLint v7 support
193208
"prefer-promise-reject-errors": "error",
194209
"prefer-regex-literals": "error",
195210
quotes: ["error", "double", { avoidEscape: true }],

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,9 @@
5353
"vue-eslint-parser": "^8.3.0"
5454
},
5555
"devDependencies": {
56-
"@eslint/eslintrc": "^0.4.3",
56+
"@eslint/eslintrc": "^1.3.3",
5757
"@eslint-community/eslint-plugin-mysticatea": "file:.",
58-
"eslint": "~7.32.0",
58+
"eslint": "~8.27.0",
5959
"globals": "^13.17.0",
6060
"mocha": "^9.2.2",
6161
"npm-run-all": "^4.1.5",
@@ -65,7 +65,7 @@
6565
"typescript": "^4.8.4"
6666
},
6767
"peerDependencies": {
68-
"eslint": ">=6.6.0"
68+
"eslint": "^6.6.0 || ^7.0.0 || ^8.0.0"
6969
},
7070
"engines": {
7171
"node": "^12.22.0 || ^14.17.0 || >=16.0.0"

tests/lib/configs/_rules.js

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,12 @@
66

77
const { Linter } = require("eslint")
88
const {
9-
ConfigArrayFactory,
10-
} = require("@eslint/eslintrc/lib/config-array-factory")
11-
const Validator = require("eslint/lib/shared/config-validator")
12-
const { rules: removedRules } = require("eslint/conf/replacements.json")
9+
Legacy: { ConfigArrayFactory, ConfigValidator },
10+
} = require("@eslint/eslintrc")
1311
const {
1412
rules: PluginRulesIndex,
1513
} = require("@eslint-community/eslint-plugin-mysticatea")
14+
const { rules: removedRules } = require("./eslint-replacements.json")
1615

1716
const coreRules = new Linter().getRules()
1817
const pluginRules = new Map(
@@ -31,6 +30,7 @@ const deprecatedRuleNames = new Set(
3130
const removedRuleNames = new Set(Object.keys(removedRules))
3231

3332
const configFactory = new ConfigArrayFactory()
33+
const configValidator = new ConfigValidator()
3434

3535
module.exports = {
3636
/**
@@ -40,7 +40,9 @@ module.exports = {
4040
* @returns {void}
4141
*/
4242
validateConfig(config, source) {
43-
Validator.validate(config, source, (ruleId) => allRules.get(ruleId))
43+
configValidator.validate(config, source, (ruleId) =>
44+
allRules.get(ruleId)
45+
)
4446

4547
/* istanbul ignore next */
4648
for (const ruleId of [].concat(
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
{
2+
"rules": {
3+
"generator-star": ["generator-star-spacing"],
4+
"global-strict": ["strict"],
5+
"no-arrow-condition": ["no-confusing-arrow", "no-constant-condition"],
6+
"no-comma-dangle": ["comma-dangle"],
7+
"no-empty-class": ["no-empty-character-class"],
8+
"no-empty-label": ["no-labels"],
9+
"no-extra-strict": ["strict"],
10+
"no-reserved-keys": ["quote-props"],
11+
"no-space-before-semi": ["semi-spacing"],
12+
"no-wrap-func": ["no-extra-parens"],
13+
"space-after-function-name": ["space-before-function-paren"],
14+
"space-after-keywords": ["keyword-spacing"],
15+
"space-before-function-parentheses": ["space-before-function-paren"],
16+
"space-before-keywords": ["keyword-spacing"],
17+
"space-in-brackets": [
18+
"object-curly-spacing",
19+
"array-bracket-spacing",
20+
"computed-property-spacing"
21+
],
22+
"space-return-throw-case": ["keyword-spacing"],
23+
"space-unary-word-ops": ["space-unary-ops"],
24+
"spaced-line-comment": ["spaced-comment"]
25+
}
26+
}

0 commit comments

Comments
 (0)