Skip to content

Commit 43cd406

Browse files
committed
feat: support ESLint 8.x
BREAKING CHANGE: Requires Node@^12.22.0 || ^14.17.0 || >=16.0.0 BREAKING CHANGE: Requires ESLint@^8.0.0
1 parent f9c4c6b commit 43cd406

20 files changed

+84
-105
lines changed

.github/workflows/CI.yml

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ jobs:
1313
strategy:
1414
matrix:
1515
os: [ubuntu-latest]
16-
eslint: [7]
16+
eslint: [8]
1717
node: [16]
1818
include:
1919
# On other platforms
@@ -26,10 +26,8 @@ jobs:
2626
os: ubuntu-latest
2727
- node: 12
2828
os: ubuntu-latest
29-
- node: 10
30-
os: ubuntu-latest
3129
# On the minimum supported ESLint/Node.js version
32-
- node: 10.12.0
30+
- node: 12.22.0
3331
os: ubuntu-latest
3432

3533
runs-on: ${{ matrix.os }}

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ npm install --save-dev eslint @mysticatea/eslint-plugin
1616

1717
### Requirements
1818

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

2222
## 📖 Usage
2323

lib/configs/_override-vue.js

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -77,10 +77,7 @@ module.exports = {
7777
"error",
7878
{
7979
singleline: 3,
80-
multiline: {
81-
max: 1,
82-
allowFirstLine: false,
83-
},
80+
multiline: 1,
8481
},
8582
],
8683
"@mysticatea/vue/max-len": ["error", { tabWidth: 4 }],

lib/processors/vue.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ module.exports = {
2222
}
2323

2424
// Filter messages which are in disabled area.
25-
return messages[0].filter(message => {
25+
return messages[0].filter((message) => {
2626
if (message.ruleId === "@mysticatea/vue/comment-directive") {
2727
const rules = message.message.split(" ")
2828
const type = rules.shift()

lib/rules/arrow-parens.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,7 @@ module.exports = {
3030
description: "enforce the parentheses style of arrow functions.",
3131
category: "Stylistic Issues",
3232
recommended: false,
33-
url:
34-
"https://github.com/mysticatea/eslint-plugin/blob/v13.0.0/docs/rules/arrow-parens.md",
33+
url: "https://github.com/mysticatea/eslint-plugin/blob/v13.0.0/docs/rules/arrow-parens.md",
3534
},
3635
fixable: "code",
3736
schema: [],

lib/rules/block-scoped-var.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,10 @@
99
// Helpers
1010
//------------------------------------------------------------------------------
1111

12-
const scopeNodeType = /^(?:(?:Block|Switch|For(?:In|Of)?)Statement|CatchClause|Program)$/u
13-
const containerNodeType = /^(?:For(?:In|Of)?Statement|(?:Arrow)?Function(?:Declaration|Expression))$/u
12+
const scopeNodeType =
13+
/^(?:(?:Block|Switch|For(?:In|Of)?)Statement|CatchClause|Program)$/u
14+
const containerNodeType =
15+
/^(?:For(?:In|Of)?Statement|(?:Arrow)?Function(?:Declaration|Expression))$/u
1416

1517
/**
1618
* Checks whether or not a given definition should be skipped.
@@ -196,8 +198,7 @@ module.exports = {
196198
description: "disallow illegal usage of variables as block-scoped.",
197199
category: "Possible Errors",
198200
recommended: false,
199-
url:
200-
"https://github.com/mysticatea/eslint-plugin/blob/v13.0.0/docs/rules/block-scoped-var.md",
201+
url: "https://github.com/mysticatea/eslint-plugin/blob/v13.0.0/docs/rules/block-scoped-var.md",
201202
},
202203
fixable: null,
203204
schema: [],

lib/rules/no-instanceof-array.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,7 @@ module.exports = {
1414
docs: {
1515
description: "disallow 'instanceof' for Array",
1616
category: "Best Practices",
17-
url:
18-
"https://github.com/mysticatea/eslint-plugin/blob/v13.0.0/docs/rules/no-instanceof-array.md",
17+
url: "https://github.com/mysticatea/eslint-plugin/blob/v13.0.0/docs/rules/no-instanceof-array.md",
1918
},
2019
fixable: "code",
2120
schema: [],
@@ -64,7 +63,7 @@ module.exports = {
6463
loc: node.loc,
6564
message:
6665
"Unexpected 'instanceof' operator. Use 'Array.isArray' instead.",
67-
fix: fixer =>
66+
fix: (fixer) =>
6867
fixer.replaceText(
6968
node,
7069
`Array.isArray(${sourceCode.getText(

lib/rules/no-instanceof-wrapper.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,7 @@ module.exports = {
1414
docs: {
1515
description: "disallow 'instanceof' for wrapper objects",
1616
category: "Best Practices",
17-
url:
18-
"https://github.com/mysticatea/eslint-plugin/blob/v13.0.0/docs/rules/no-instanceof-wrapper.md",
17+
url: "https://github.com/mysticatea/eslint-plugin/blob/v13.0.0/docs/rules/no-instanceof-wrapper.md",
1918
},
2019
fixable: "code",
2120
schema: [],
@@ -76,7 +75,7 @@ module.exports = {
7675
message:
7776
"Unexpected 'instanceof' operator. Use 'typeof x === \"{{typeName}}\"' instead.",
7877
data: { typeName },
79-
fix: fixer =>
78+
fix: (fixer) =>
8079
fixer.replaceText(
8180
node,
8281
`typeof ${sourceCode.getText(

lib/rules/no-literal-call.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@
99
//------------------------------------------------------------------------------
1010

1111
const LITERAL_TYPE = /^(?:(?:Array|Object)Expression|(?:Template)?Literal)$/u
12-
const LITERAL_AND_CLASS_TYPE = /^(?:(?:Array|Class|Object)Expression|(?:Template)?Literal)$/u
12+
const LITERAL_AND_CLASS_TYPE =
13+
/^(?:(?:Array|Class|Object)Expression|(?:Template)?Literal)$/u
1314

1415
//------------------------------------------------------------------------------
1516
// Rule Definition
@@ -21,8 +22,7 @@ module.exports = {
2122
description: "disallow a call of a literal.",
2223
category: "Possible Errors",
2324
recommended: false,
24-
url:
25-
"https://github.com/mysticatea/eslint-plugin/blob/v13.0.0/docs/rules/no-literal-call.md",
25+
url: "https://github.com/mysticatea/eslint-plugin/blob/v13.0.0/docs/rules/no-literal-call.md",
2626
},
2727
fixable: null,
2828
schema: [],

lib/rules/no-this-in-static.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,7 @@ module.exports = {
1414
docs: {
1515
description: "disallow `this`/`super` in static methods",
1616
category: "Best Practices",
17-
url:
18-
"https://github.com/mysticatea/eslint-plugin/blob/v13.0.0/docs/rules/no-this-in-static.md",
17+
url: "https://github.com/mysticatea/eslint-plugin/blob/v13.0.0/docs/rules/no-this-in-static.md",
1918
},
2019
fixable: null,
2120
schema: [],

lib/rules/no-use-ignored-vars.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,7 @@ module.exports = {
2020
description: "disallow a use of ignored variables.",
2121
category: "Stylistic Issues",
2222
recommended: false,
23-
url:
24-
"https://github.com/mysticatea/eslint-plugin/blob/v13.0.0/docs/rules/no-use-ignored-vars.md",
23+
url: "https://github.com/mysticatea/eslint-plugin/blob/v13.0.0/docs/rules/no-use-ignored-vars.md",
2524
},
2625
fixable: null,
2726
schema: [{ type: "string" }],

lib/rules/no-useless-rest-spread.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@
88
// Helpers
99
//------------------------------------------------------------------------------
1010

11-
const FUNC_TYPE = /^(?:FunctionDeclaration|(?:New|Call|(?:Arrow)?Function)Expression)$/u
11+
const FUNC_TYPE =
12+
/^(?:FunctionDeclaration|(?:New|Call|(?:Arrow)?Function)Expression)$/u
1213
const PROPERTY_PATTERN = /^(?:Experimental)?(Rest|Spread)Property$/u
1314

1415
/**
@@ -56,7 +57,7 @@ function getLastElementToken(sourceCode, node) {
5657
* @returns {function} A fixer function.
5758
*/
5859
function defineFixer(sourceCode, node) {
59-
return fixer => {
60+
return (fixer) => {
6061
const child = node.argument
6162

6263
// If the inner array includes holes, do nothing.
@@ -97,8 +98,7 @@ module.exports = {
9798
description: "disallow unnecessary spread operators.",
9899
category: "Best Practices",
99100
recommended: false,
100-
url:
101-
"https://github.com/mysticatea/eslint-plugin/blob/v13.0.0/docs/rules/no-useless-rest-spread.md",
101+
url: "https://github.com/mysticatea/eslint-plugin/blob/v13.0.0/docs/rules/no-useless-rest-spread.md",
102102
},
103103
fixable: "code",
104104
schema: [],
@@ -116,7 +116,7 @@ module.exports = {
116116
function verify(node) {
117117
const nodeType = node.type.replace(
118118
PROPERTY_PATTERN,
119-
t => `${t}Element`
119+
(t) => `${t}Element`
120120
)
121121
const parentType = node.parent.type
122122
const argumentType = node.argument.type

lib/rules/prefer-for-of.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,7 @@ function isIndexVarOnlyUsedToGetArrayElements(context, node) {
243243
const arrayText = getArrayTextOfForStatement(sourceCode, node)
244244
const indexVar = context.getDeclaredVariables(node.init)[0]
245245

246-
return indexVar.references.every(reference => {
246+
return indexVar.references.every((reference) => {
247247
const id = reference.identifier
248248

249249
return (
@@ -273,7 +273,8 @@ function isLengthVarOnlyUsedToTest(context, node) {
273273
const lengthVar = context.getDeclaredVariables(node.init.declarations[1])[0]
274274

275275
return lengthVar.references.every(
276-
reference => reference.init || contains(node.test, reference.identifier)
276+
(reference) =>
277+
reference.init || contains(node.test, reference.identifier)
277278
)
278279
}
279280

@@ -497,8 +498,7 @@ module.exports = {
497498
description: "requires for-of statements instead of Array#forEach",
498499
category: "Best Practices",
499500
recommended: false,
500-
url:
501-
"https://github.com/mysticatea/eslint-plugin/blob/v13.0.0/docs/rules/prefer-for-of.md",
501+
url: "https://github.com/mysticatea/eslint-plugin/blob/v13.0.0/docs/rules/prefer-for-of.md",
502502
},
503503
fixable: "code",
504504
schema: [],
@@ -580,7 +580,7 @@ module.exports = {
580580
if (
581581
thisFuncInfo != null &&
582582
thisFuncInfo.isTarget &&
583-
!thisFuncInfo.returnNodes.some(returnNode =>
583+
!thisFuncInfo.returnNodes.some((returnNode) =>
584584
contains(returnNode, node)
585585
)
586586
) {

package.json

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,31 +3,31 @@
33
"version": "13.0.0",
44
"description": "Additional ESLint rules.",
55
"engines": {
6-
"node": "^10.12.0 || >=12.0.0"
6+
"node": "^12.22.0 || ^14.17.0 || >=16.0.0"
77
},
88
"main": "index.js",
99
"files": [
1010
"lib"
1111
],
1212
"peerDependencies": {
13-
"eslint": "^7.0.0"
13+
"eslint": "^8.0.0"
1414
},
1515
"dependencies": {
16-
"@eslint/eslintrc": "^0.4.3",
17-
"@typescript-eslint/eslint-plugin": "^4.33.0",
18-
"@typescript-eslint/parser": "^4.33.0",
16+
"@eslint/eslintrc": "^1.0.3",
17+
"@typescript-eslint/eslint-plugin": "^5.2.0",
18+
"@typescript-eslint/parser": "^5.2.0",
1919
"eslint-plugin-eslint-comments": "^3.2.0",
20-
"eslint-plugin-eslint-plugin": "^3.6.1",
20+
"eslint-plugin-eslint-plugin": "^4.0.2",
2121
"eslint-plugin-node": "^11.1.0",
22-
"eslint-plugin-prettier": "^3.4.1",
23-
"eslint-plugin-vue": "^7.19.1",
24-
"prettier": "^1.19.1",
25-
"vue-eslint-parser": "^7.11.0"
22+
"eslint-plugin-prettier": "^4.0.0",
23+
"eslint-plugin-vue": "^8.0.3",
24+
"prettier": "^2.4.1",
25+
"vue-eslint-parser": "^8.0.1"
2626
},
2727
"devDependencies": {
2828
"@mysticatea/eslint-plugin": "file:.",
2929
"codecov": "^3.6.1",
30-
"eslint": "^7.32.0",
30+
"eslint": "^8.1.0",
3131
"fs-extra": "^8.1.0",
3232
"globals": "^12.1.1",
3333
"mocha": "^6.2.2",

scripts/generate-browser-globals.js

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
const fs = require("fs")
88
const path = require("path")
9-
const { CLIEngine } = require("eslint")
9+
const { ESLint } = require("eslint")
1010
const { browser: originalGlobals } = require("globals")
1111

1212
const targetFile = path.resolve(__dirname, "../lib/configs/_browser-globals.js")
@@ -33,7 +33,7 @@ for (const key of Object.keys(originalGlobals).sort()) {
3333
}
3434
}
3535

36-
const linter = new CLIEngine({ fix: true })
36+
const linter = new ESLint({ fix: true })
3737
const rawCode = `/**
3838
* DON'T EDIT THIS FILE WHICH WAS GENERATED BY './scripts/generate-browser-globals.js'.
3939
*/
@@ -42,7 +42,6 @@ const rawCode = `/**
4242
module.exports = ${JSON.stringify(globals, null, 4)}
4343
`
4444
const code =
45-
linter.executeOnText(rawCode, "_browser-globals.js").results[0].output ||
46-
rawCode
45+
linter.lintText(rawCode, "_browser-globals.js").results[0].output || rawCode
4746

4847
fs.writeFileSync(targetFile, code)

scripts/generate-configs.js

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

77
const fs = require("fs")
88
const path = require("path")
9-
const { CLIEngine } = require("eslint")
9+
const { ESLint } = require("eslint")
1010

1111
const targetFile = path.resolve(__dirname, "../lib/configs.js")
1212

@@ -20,14 +20,14 @@ fs.writeFileSync(
2020
module.exports = {
2121
${fs
2222
.readdirSync(path.resolve(__dirname, "../lib/configs"))
23-
.map(fileName => path.basename(fileName, ".js"))
24-
.filter(id => !id.startsWith("_"))
25-
.map(id => ` "${id}": require("./configs/${id}"),`)
23+
.map((fileName) => path.basename(fileName, ".js"))
24+
.filter((id) => !id.startsWith("_"))
25+
.map((id) => ` "${id}": require("./configs/${id}"),`)
2626
.join("\n")}
2727
}
2828
`
2929
)
3030

31-
const linter = new CLIEngine({ fix: true })
32-
const result = linter.executeOnFiles([targetFile])
33-
CLIEngine.outputFixes(result)
31+
const linter = new ESLint({ fix: true })
32+
const result = linter.lintFiles([targetFile])
33+
ESLint.outputFixes(result)

scripts/generate-rules.js

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

77
const fs = require("fs")
88
const path = require("path")
9-
const { CLIEngine } = require("eslint")
9+
const { ESLint } = require("eslint")
1010

1111
const targetFile = path.resolve(__dirname, "../lib/rules.js")
1212

@@ -20,20 +20,20 @@ fs.writeFileSync(
2020
module.exports = Object.assign(
2121
${fs
2222
.readdirSync(path.resolve(__dirname, "../lib/foreign-rules"))
23-
.map(fileName => path.basename(fileName, ".js"))
24-
.map(id => ` require("./foreign-rules/${id}"),`)
23+
.map((fileName) => path.basename(fileName, ".js"))
24+
.map((id) => ` require("./foreign-rules/${id}"),`)
2525
.join("\n")}
2626
{
2727
${fs
2828
.readdirSync(path.resolve(__dirname, "../lib/rules"))
29-
.map(fileName => path.basename(fileName, ".js"))
30-
.map(id => ` "${id}": require("./rules/${id}"),`)
29+
.map((fileName) => path.basename(fileName, ".js"))
30+
.map((id) => ` "${id}": require("./rules/${id}"),`)
3131
.join("\n")}
3232
}
3333
)
3434
`
3535
)
3636

37-
const linter = new CLIEngine({ fix: true })
38-
const result = linter.executeOnFiles([targetFile])
39-
CLIEngine.outputFixes(result)
37+
const linter = new ESLint({ fix: true })
38+
const result = linter.lintFiles([targetFile])
39+
ESLint.outputFixes(result)

0 commit comments

Comments
 (0)