From c51cd082e4d17b9d06134c2d62b5f2851d41e287 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C3=ABl=20De=20Boey?= Date: Mon, 23 Aug 2021 02:28:38 +0200 Subject: [PATCH] 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 --- .github/workflows/CI.yml | 6 ++---- README.md | 4 ++-- package.json | 8 ++++---- scripts/generate-browser-globals.js | 7 +++---- scripts/generate-configs.js | 8 ++++---- scripts/generate-rules.js | 8 ++++---- tests/lib/configs/_rules.js | 6 +++--- 7 files changed, 22 insertions(+), 25 deletions(-) diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index 317dd08..0cdd562 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -13,7 +13,7 @@ jobs: strategy: matrix: os: [ubuntu-latest] - eslint: [7] + eslint: [8] node: [16] include: # On other platforms @@ -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 }} diff --git a/README.md b/README.md index 0f80663..8166746 100644 --- a/README.md +++ b/README.md @@ -16,8 +16,8 @@ npm install --save-dev eslint @mysticatea/eslint-plugin ### Requirements -- Node.js `^10.12.0 || >=12.0.0` or newer versions. -- ESLint `^7.0.0` or newer versions. +- Node.js `^12.22.0 || ^14.17.0 || >=16.0.0` or newer versions. +- ESLint `^8.0.0` or newer versions. ## 📖 Usage diff --git a/package.json b/package.json index 7575aac..d9ef8a0 100644 --- a/package.json +++ b/package.json @@ -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" }, "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", @@ -27,7 +27,7 @@ "devDependencies": { "@mysticatea/eslint-plugin": "file:.", "codecov": "^3.6.1", - "eslint": "^7.32.0", + "eslint": "^8.0.0", "fs-extra": "^8.1.0", "globals": "^12.1.1", "mocha": "^6.2.2", diff --git a/scripts/generate-browser-globals.js b/scripts/generate-browser-globals.js index 7b3bcfe..290aa46 100644 --- a/scripts/generate-browser-globals.js +++ b/scripts/generate-browser-globals.js @@ -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") @@ -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'. */ @@ -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) diff --git a/scripts/generate-configs.js b/scripts/generate-configs.js index a0587d1..0326572 100644 --- a/scripts/generate-configs.js +++ b/scripts/generate-configs.js @@ -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") @@ -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) diff --git a/scripts/generate-rules.js b/scripts/generate-rules.js index 141e876..8d78203 100644 --- a/scripts/generate-rules.js +++ b/scripts/generate-rules.js @@ -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") @@ -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) diff --git a/tests/lib/configs/_rules.js b/tests/lib/configs/_rules.js index b46dcde..24a6d6f 100644 --- a/tests/lib/configs/_rules.js +++ b/tests/lib/configs/_rules.js @@ -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") @@ -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(