From 213b3aa77b100cbc1e0401c324caef2833fac66c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C3=ABl=20De=20Boey?= Date: Sat, 18 Dec 2021 06:03:23 +0100 Subject: [PATCH] chore: fix ESLint errors --- .eslintrc.yml | 15 +++++++++++++++ tests/lib/configs/_rules.js | 5 ++--- tests/lib/configs/browser.js | 3 +-- tests/lib/configs/es2015.js | 2 +- tests/lib/configs/es2016.js | 3 +-- tests/lib/configs/es2017.js | 3 +-- tests/lib/configs/es2018.js | 3 +-- tests/lib/configs/es2019.js | 3 +-- tests/lib/configs/es2020.js | 3 +-- tests/lib/configs/es5.js | 2 +- tests/lib/configs/eslint-plugin.js | 2 +- tests/lib/configs/mocha.js | 3 +-- tests/lib/configs/modules.js | 3 +-- tests/lib/configs/node.js | 2 +- tests/lib/configs/special.js | 3 +-- tests/lib/configs/ts.js | 2 +- tests/lib/configs/vue.js | 2 +- 17 files changed, 32 insertions(+), 27 deletions(-) diff --git a/.eslintrc.yml b/.eslintrc.yml index 6683556..eb77061 100644 --- a/.eslintrc.yml +++ b/.eslintrc.yml @@ -2,3 +2,18 @@ root: true extends: - plugin:@mysticatea/es2015 - plugin:@mysticatea/+eslint-plugin + +overrides: + - files: [ "lib/utils.js", "scripts/*.js" ] + rules: + "@mysticatea/node/no-sync": off + + - files: + [ + "lib/configs.js", + "lib/foreign-rules/ts.js", + "lib/processors.js", + "lib/rules.js", + ] + rules: + "@mysticatea/node/global-require": off diff --git a/tests/lib/configs/_rules.js b/tests/lib/configs/_rules.js index 170f2cb..d1b5ddf 100644 --- a/tests/lib/configs/_rules.js +++ b/tests/lib/configs/_rules.js @@ -9,6 +9,7 @@ const { ConfigArrayFactory, } = require("eslint/lib/cli-engine/config-array-factory") const Validator = require("eslint/lib/shared/config-validator") +const { rules: removedRules } = require("eslint/conf/replacements.json") const { rules: PluginRulesIndex } = require("@mysticatea/eslint-plugin") const coreRules = new Linter().getRules() @@ -25,9 +26,7 @@ const deprecatedRuleNames = new Set( .filter(([, rule]) => rule && rule.meta && rule.meta.deprecated) .map(([ruleId]) => ruleId) ) -const removedRuleNames = new Set( - Object.keys(require("eslint/conf/replacements.json").rules) -) +const removedRuleNames = new Set(Object.keys(removedRules)) const configFactory = new ConfigArrayFactory() diff --git a/tests/lib/configs/browser.js b/tests/lib/configs/browser.js index d37e11b..8920e03 100644 --- a/tests/lib/configs/browser.js +++ b/tests/lib/configs/browser.js @@ -5,11 +5,10 @@ */ "use strict" +const config = require("../../../lib/configs/+browser") const Rules = require("./_rules") describe("'+browser.js'", () => { - const config = require("../../../lib/configs/+browser") - it("should be a valid config.", () => { Rules.validateConfig(config, "+browser.js") }) diff --git a/tests/lib/configs/es2015.js b/tests/lib/configs/es2015.js index fe430b2..2564d5c 100644 --- a/tests/lib/configs/es2015.js +++ b/tests/lib/configs/es2015.js @@ -6,6 +6,7 @@ "use strict" const assert = require("assert") +const config = require("../../../lib/configs/es2015") const Rules = require("./_rules") /** @@ -22,7 +23,6 @@ function isES6Rule(ruleId) { } describe("'es2015.js'", () => { - const config = require("../../../lib/configs/es2015") const configuredRules = Rules.getRulesOfConfig(config, "es2015") const existingRules = Rules.getCoreRuleNames() diff --git a/tests/lib/configs/es2016.js b/tests/lib/configs/es2016.js index 77dc687..a0db951 100644 --- a/tests/lib/configs/es2016.js +++ b/tests/lib/configs/es2016.js @@ -5,11 +5,10 @@ */ "use strict" +const config = require("../../../lib/configs/es2016") const Rules = require("./_rules") describe("'es2016.js'", () => { - const config = require("../../../lib/configs/es2016") - it("should be a valid config.", () => { Rules.validateConfig(config, "es2016.js") }) diff --git a/tests/lib/configs/es2017.js b/tests/lib/configs/es2017.js index 5101b53..746a45a 100644 --- a/tests/lib/configs/es2017.js +++ b/tests/lib/configs/es2017.js @@ -5,11 +5,10 @@ */ "use strict" +const config = require("../../../lib/configs/es2017") const Rules = require("./_rules") describe("'es2017.js'", () => { - const config = require("../../../lib/configs/es2017") - it("should be a valid config.", () => { Rules.validateConfig(config, "es2017.js") }) diff --git a/tests/lib/configs/es2018.js b/tests/lib/configs/es2018.js index deccfd0..d7b1fca 100644 --- a/tests/lib/configs/es2018.js +++ b/tests/lib/configs/es2018.js @@ -5,11 +5,10 @@ */ "use strict" +const config = require("../../../lib/configs/es2018") const Rules = require("./_rules") describe("'es2018.js'", () => { - const config = require("../../../lib/configs/es2018") - it("should be a valid config.", () => { Rules.validateConfig(config, "es2018.js") }) diff --git a/tests/lib/configs/es2019.js b/tests/lib/configs/es2019.js index 31e1420..ff75bb6 100644 --- a/tests/lib/configs/es2019.js +++ b/tests/lib/configs/es2019.js @@ -4,11 +4,10 @@ */ "use strict" +const config = require("../../../lib/configs/es2019") const Rules = require("./_rules") describe("'es2019.js'", () => { - const config = require("../../../lib/configs/es2019") - it("should be a valid config.", () => { Rules.validateConfig(config, "es2019.js") }) diff --git a/tests/lib/configs/es2020.js b/tests/lib/configs/es2020.js index cb1611a..03ba982 100644 --- a/tests/lib/configs/es2020.js +++ b/tests/lib/configs/es2020.js @@ -4,11 +4,10 @@ */ "use strict" +const config = require("../../../lib/configs/es2020") const Rules = require("./_rules") describe("'es2020.js'", () => { - const config = require("../../../lib/configs/es2020") - it("should be a valid config.", () => { Rules.validateConfig(config, "es2020.js") }) diff --git a/tests/lib/configs/es5.js b/tests/lib/configs/es5.js index 63caafd..d3fd708 100644 --- a/tests/lib/configs/es5.js +++ b/tests/lib/configs/es5.js @@ -6,6 +6,7 @@ "use strict" const assert = require("assert") +const config = require("../../../lib/configs/es5") const Rules = require("./_rules") /** @@ -22,7 +23,6 @@ function isES6Rule(ruleId) { } describe("'es5.js'", () => { - const config = require("../../../lib/configs/es5") const configuredRules = Rules.getRulesOfConfig(config, "es5") const existingRules = [].concat( Rules.getCoreRuleNames(), diff --git a/tests/lib/configs/eslint-plugin.js b/tests/lib/configs/eslint-plugin.js index 7576c68..f285a90 100644 --- a/tests/lib/configs/eslint-plugin.js +++ b/tests/lib/configs/eslint-plugin.js @@ -6,10 +6,10 @@ "use strict" const assert = require("assert") +const config = require("../../../lib/configs/+eslint-plugin") const Rules = require("./_rules") describe("'+eslint-plugin.js'", () => { - const config = require("../../../lib/configs/+eslint-plugin") const configuredRules = Rules.getRulesOfConfig(config, "+eslint-plugin") const existingRules = Rules.getPluginRuleNames("eslint-plugin") diff --git a/tests/lib/configs/mocha.js b/tests/lib/configs/mocha.js index 8b12408..c994ac7 100644 --- a/tests/lib/configs/mocha.js +++ b/tests/lib/configs/mocha.js @@ -5,11 +5,10 @@ */ "use strict" +const config = require("../../../lib/configs/_override-mocha") const Rules = require("./_rules") describe("'mocha.js'", () => { - const config = require("../../../lib/configs/_override-mocha") - it("should be a valid config.", () => { Rules.validateConfig(config, "mocha.js") }) diff --git a/tests/lib/configs/modules.js b/tests/lib/configs/modules.js index 343f9fc..10c7d97 100644 --- a/tests/lib/configs/modules.js +++ b/tests/lib/configs/modules.js @@ -5,11 +5,10 @@ */ "use strict" +const config = require("../../../lib/configs/+modules") const Rules = require("./_rules") describe("'+modules.js'", () => { - const config = require("../../../lib/configs/+modules") - it("should be a valid config.", () => { Rules.validateConfig(config, "+modules.js") }) diff --git a/tests/lib/configs/node.js b/tests/lib/configs/node.js index 7077389..450154b 100644 --- a/tests/lib/configs/node.js +++ b/tests/lib/configs/node.js @@ -6,10 +6,10 @@ "use strict" const assert = require("assert") +const config = require("../../../lib/configs/+node") const Rules = require("./_rules") describe("'+node.js'", () => { - const config = require("../../../lib/configs/+node") const configuredRules = Rules.getRulesOfConfig(config, "+node") const existingRules = Rules.getPluginRuleNames("node") diff --git a/tests/lib/configs/special.js b/tests/lib/configs/special.js index c0de8de..2ff2f8c 100644 --- a/tests/lib/configs/special.js +++ b/tests/lib/configs/special.js @@ -5,11 +5,10 @@ */ "use strict" +const config = require("../../../lib/configs/_override-special") const Rules = require("./_rules") describe("'special.js'", () => { - const config = require("../../../lib/configs/_override-special") - it("should be a valid config.", () => { Rules.validateConfig(config, "special.js") }) diff --git a/tests/lib/configs/ts.js b/tests/lib/configs/ts.js index e671575..70a325d 100644 --- a/tests/lib/configs/ts.js +++ b/tests/lib/configs/ts.js @@ -6,10 +6,10 @@ "use strict" const assert = require("assert") +const config = require("../../../lib/configs/_override-ts") const Rules = require("./_rules") describe("'ts.js'", () => { - const config = require("../../../lib/configs/_override-ts") const configuredRules = Rules.getRulesOfConfig(config, "_override-ts") const existingRules = Rules.getPluginRuleNames("ts") diff --git a/tests/lib/configs/vue.js b/tests/lib/configs/vue.js index 83541fd..6c8f514 100644 --- a/tests/lib/configs/vue.js +++ b/tests/lib/configs/vue.js @@ -6,10 +6,10 @@ "use strict" const assert = require("assert") +const config = require("../../../lib/configs/_override-vue") const Rules = require("./_rules") describe("'vue.js'", () => { - const config = require("../../../lib/configs/_override-vue") const configuredRules = Rules.getRulesOfConfig(config, "_override-ts") const existingRules = Rules.getPluginRuleNames("vue")