Skip to content

Commit

Permalink
feat: Support ESLint 8.x
Browse files Browse the repository at this point in the history
BREAKING CHANGE: Requires Node@^12.22.0 || ^14.17.0 || >=16.0.0
BREAKING CHANGE: Requires ESLint@^8.x
  • Loading branch information
MichaelDeBoey committed Aug 23, 2021
1 parent addbfd5 commit 776fb8a
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 23 deletions.
6 changes: 2 additions & 4 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
strategy:
matrix:
os: [ubuntu-latest]
eslint: [7]
eslint: ["^8.0.0-0"]
node: [16]
include:
# On other platforms
Expand All @@ -26,10 +26,8 @@ jobs:
os: ubuntu-latest
- node: 12
os: ubuntu-latest
- node: 10
os: ubuntu-latest
# On the minimum supported ESLint/Node.js version
- node: 10.12.0
- node: 12.22.0
os: ubuntu-latest

runs-on: ${{ matrix.os }}
Expand Down
8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,17 @@
"version": "13.0.0",
"description": "Additional ESLint rules.",
"engines": {
"node": "^10.12.0 || >=12.0.0"
"node": "^12.22.0 || ^14.17.0 || >=16.0.0"
},
"main": "index.js",
"files": [
"lib"
],
"peerDependencies": {
"eslint": "^7.0.0"
"eslint": "^8.0.0-0"
},
"dependencies": {
"@eslint/eslintrc": "^0.4.3",
"@eslint/eslintrc": "^1.0.0",
"@typescript-eslint/eslint-plugin": "^4.29.2",
"@typescript-eslint/parser": "^4.29.2",
"eslint-plugin-eslint-comments": "^3.2.0",
Expand All @@ -27,7 +27,7 @@
"devDependencies": {
"@mysticatea/eslint-plugin": "file:.",
"codecov": "^3.6.1",
"eslint": "^7.32.0",
"eslint": "^8.0.0-0",
"fs-extra": "^8.1.0",
"globals": "^12.1.1",
"mocha": "^6.2.2",
Expand Down
7 changes: 3 additions & 4 deletions scripts/generate-browser-globals.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

const fs = require("fs")
const path = require("path")
const { CLIEngine } = require("eslint")
const { ESLint } = require("eslint")
const { browser: originalGlobals } = require("globals")

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

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

fs.writeFileSync(targetFile, code)
8 changes: 4 additions & 4 deletions scripts/generate-configs.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

const fs = require("fs")
const path = require("path")
const { CLIEngine } = require("eslint")
const { ESLint } = require("eslint")

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

Expand All @@ -28,6 +28,6 @@ ${fs
`
)

const linter = new CLIEngine({ fix: true })
const result = linter.executeOnFiles([targetFile])
CLIEngine.outputFixes(result)
const linter = new ESLint({ fix: true })
const result = linter.lintFiles([targetFile])
ESLint.outputFixes(result)
8 changes: 4 additions & 4 deletions scripts/generate-rules.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

const fs = require("fs")
const path = require("path")
const { CLIEngine } = require("eslint")
const { ESLint } = require("eslint")

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

Expand Down Expand Up @@ -34,6 +34,6 @@ ${fs
`
)

const linter = new CLIEngine({ fix: true })
const result = linter.executeOnFiles([targetFile])
CLIEngine.outputFixes(result)
const linter = new ESLint({ fix: true })
const result = linter.lintFiles([targetFile])
ESLint.outputFixes(result)
6 changes: 3 additions & 3 deletions tests/lib/configs/_rules.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
const { Linter } = require("eslint")
const {
ConfigArrayFactory,
} = require("@eslint/eslintrc/lib/config-array-factory")
const Validator = require("eslint/lib/shared/config-validator")
Legacy: { ConfigValidator },
} = require("@eslint/eslintrc")
const { rules: PluginRulesIndex } = require("@mysticatea/eslint-plugin")
const { rules: removedRules } = require("eslint/conf/replacements.json")

Expand Down Expand Up @@ -38,7 +38,7 @@ module.exports = {
* @returns {void}
*/
validateConfig(config, source) {
Validator.validate(config, source, ruleId => allRules.get(ruleId))
ConfigValidator.validate(config, source, ruleId => allRules.get(ruleId))

/* istanbul ignore next */
for (const ruleId of [].concat(
Expand Down

0 comments on commit 776fb8a

Please sign in to comment.