Skip to content

Commit

Permalink
feat: update eslint-plugin-node + update configs (#24)
Browse files Browse the repository at this point in the history
* feat: update `eslint-plugin-node` + update configs

BREAKING CHANGE: `+node`, `es5`, `es2015`, `es2016`, `es2017`, `es2018`, `es2019`, `es2020`, `es2021` & `es2022` configs now have extra rules from `eslint-plugin-node`

* chore: fix ESLint errors
  • Loading branch information
MichaelDeBoey authored Oct 17, 2022
1 parent b08d8b6 commit bbaf218
Show file tree
Hide file tree
Showing 19 changed files with 44 additions and 28 deletions.
15 changes: 15 additions & 0 deletions .eslintrc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,18 @@ root: true
extends:
- plugin:@eslint-community/mysticatea/es2015
- plugin:@eslint-community/mysticatea/+eslint-plugin

overrides:
- files: ["lib/utils.js", "scripts/*.js"]
rules:
"@eslint-community/mysticatea/node/no-sync": off

- files:
[
"lib/configs.js",
"lib/foreign-rules/ts.js",
"lib/processors.js",
"lib/rules.js",
]
rules:
"@eslint-community/mysticatea/node/global-require": off
11 changes: 11 additions & 0 deletions lib/configs/+node.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ module.exports = {
require: "readonly",
},
rules: {
"@eslint-community/mysticatea/node/callback-return": "error",
"@eslint-community/mysticatea/node/exports-style": [
"error",
"module.exports",
Expand All @@ -55,13 +56,23 @@ module.exports = {
"always",
{ ".js": "never", ".ts": "never", ".tsx": "never" },
],
"@eslint-community/mysticatea/node/global-require": "error",
"@eslint-community/mysticatea/node/handle-callback-err": "error",
"@eslint-community/mysticatea/node/no-callback-literal": "off",
"@eslint-community/mysticatea/node/no-deprecated-api": "error",
"@eslint-community/mysticatea/node/no-exports-assign": "error",
"@eslint-community/mysticatea/node/no-extraneous-import": "error",
"@eslint-community/mysticatea/node/no-extraneous-require": "error",
"@eslint-community/mysticatea/node/no-missing-import": "error",
"@eslint-community/mysticatea/node/no-missing-require": "error",
"@eslint-community/mysticatea/node/no-mixed-requires": "error",
"@eslint-community/mysticatea/node/no-new-require": "error",
"@eslint-community/mysticatea/node/no-path-concat": "error",
"@eslint-community/mysticatea/node/no-process-env": "error",
"@eslint-community/mysticatea/node/no-process-exit": "error",
"@eslint-community/mysticatea/node/no-restricted-import": "error",
"@eslint-community/mysticatea/node/no-restricted-require": "error",
"@eslint-community/mysticatea/node/no-sync": "error",
"@eslint-community/mysticatea/node/no-unpublished-bin": "error",
"@eslint-community/mysticatea/node/no-unpublished-import": "error",
"@eslint-community/mysticatea/node/no-unpublished-require": "error",
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"@typescript-eslint/parser": "^5.40.0",
"eslint-plugin-eslint-comments": "^3.2.0",
"eslint-plugin-eslint-plugin": "^4.4.1",
"eslint-plugin-node": "^10.0.0",
"eslint-plugin-node": "^11.1.0",
"eslint-plugin-prettier": "^3.4.1",
"eslint-plugin-vue": "^6.2.2",
"prettier": "^2.7.1",
Expand Down
5 changes: 2 additions & 3 deletions tests/lib/configs/_rules.js
Original file line number Diff line number Diff line change
Expand Up @@ -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("@eslint-community/eslint-plugin-mysticatea")
Expand All @@ -27,9 +28,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()

Expand Down
3 changes: 1 addition & 2 deletions tests/lib/configs/browser.js
Original file line number Diff line number Diff line change
Expand Up @@ -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")
})
Expand Down
2 changes: 1 addition & 1 deletion tests/lib/configs/es2015.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"use strict"

const assert = require("assert")
const config = require("../../../lib/configs/es2015")
const Rules = require("./_rules")

/**
Expand All @@ -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()

Expand Down
3 changes: 1 addition & 2 deletions tests/lib/configs/es2016.js
Original file line number Diff line number Diff line change
Expand Up @@ -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")
})
Expand Down
3 changes: 1 addition & 2 deletions tests/lib/configs/es2017.js
Original file line number Diff line number Diff line change
Expand Up @@ -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")
})
Expand Down
3 changes: 1 addition & 2 deletions tests/lib/configs/es2018.js
Original file line number Diff line number Diff line change
Expand Up @@ -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")
})
Expand Down
3 changes: 1 addition & 2 deletions tests/lib/configs/es2019.js
Original file line number Diff line number Diff line change
Expand Up @@ -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")
})
Expand Down
3 changes: 1 addition & 2 deletions tests/lib/configs/es2020.js
Original file line number Diff line number Diff line change
Expand Up @@ -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")
})
Expand Down
2 changes: 1 addition & 1 deletion tests/lib/configs/es5.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"use strict"

const assert = require("assert")
const config = require("../../../lib/configs/es5")
const Rules = require("./_rules")

/**
Expand All @@ -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(),
Expand Down
2 changes: 1 addition & 1 deletion tests/lib/configs/eslint-plugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -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")

Expand Down
3 changes: 1 addition & 2 deletions tests/lib/configs/mocha.js
Original file line number Diff line number Diff line change
Expand Up @@ -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")
})
Expand Down
3 changes: 1 addition & 2 deletions tests/lib/configs/modules.js
Original file line number Diff line number Diff line change
Expand Up @@ -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")
})
Expand Down
2 changes: 1 addition & 1 deletion tests/lib/configs/node.js
Original file line number Diff line number Diff line change
Expand Up @@ -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")

Expand Down
3 changes: 1 addition & 2 deletions tests/lib/configs/special.js
Original file line number Diff line number Diff line change
Expand Up @@ -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")
})
Expand Down
2 changes: 1 addition & 1 deletion tests/lib/configs/ts.js
Original file line number Diff line number Diff line change
Expand Up @@ -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")

Expand Down
2 changes: 1 addition & 1 deletion tests/lib/configs/vue.js
Original file line number Diff line number Diff line change
Expand Up @@ -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")

Expand Down

0 comments on commit bbaf218

Please sign in to comment.