Skip to content

Commit

Permalink
feat: support ESLint 8.x
Browse files Browse the repository at this point in the history
  • Loading branch information
MichaelDeBoey committed Oct 25, 2022
1 parent 9225766 commit 3640662
Show file tree
Hide file tree
Showing 6 changed files with 43 additions and 12 deletions.
9 changes: 6 additions & 3 deletions .github/workflows/CI.yml
Expand Up @@ -41,18 +41,21 @@ jobs:
matrix.os }})
strategy:
matrix:
eslint: [7]
eslint: [8]
node: [12.22.0, 12, 14.17.0, 14, 16, 18]
os: [ubuntu-latest]
include:
# On other platforms
- os: windows-latest
eslint: 7
eslint: 8
node: 18
- os: macos-latest
eslint: 7
eslint: 8
node: 18
# On old ESLint versions
- eslint: 7
node: 18
os: ubuntu-latest
- eslint: 6
node: 18
os: ubuntu-latest
Expand Down
2 changes: 1 addition & 1 deletion README.md
Expand Up @@ -17,7 +17,7 @@ npm install --save-dev eslint @eslint-community/eslint-plugin-mysticatea
### Requirements

- Node.js `^12.22.0 || ^14.17.0 || >=16.0.0` or newer versions.
- ESLint `^6.6.0 || ^7.0.0` or newer versions.
- ESLint `^6.6.0 || ^7.0.0 || ^8.0.0` or newer versions.

## 📖 Usage

Expand Down
4 changes: 4 additions & 0 deletions lib/configs/_base.js
Expand Up @@ -38,6 +38,7 @@ module.exports = {
"init-declarations": "error",
"linebreak-style": ["error", "unix"],
"lines-between-class-members": "error",
"logical-assignment-operators": "off", // TODO: enable once we drop ESLint v7 support
"max-statements-per-line": ["error", { max: 1 }],
"multiline-comment-style": ["error", "separate-lines"],
"new-cap": "error",
Expand All @@ -48,6 +49,7 @@ module.exports = {
"no-case-declarations": "error",
"no-compare-neg-zero": "error",
"no-cond-assign": "error",
"no-constant-binary-expression": "off", // TODO: enable once we drop ESLint v7 support
"no-constant-condition": "error",
"no-constructor-return": "error",
"no-control-regex": "error",
Expand Down Expand Up @@ -152,6 +154,7 @@ module.exports = {
"no-unsafe-optional-chaining": "error",
"no-unused-expressions": "error",
"no-unused-labels": "error",
"no-unused-private-class-members": "off", // TODO: enable once we drop ESLint v7 support
"no-unused-vars": [
"error",
{
Expand Down Expand Up @@ -185,6 +188,7 @@ module.exports = {
{ blankLine: "always", next: "*", prev: "function" },
],
"prefer-exponentiation-operator": "error",
"prefer-object-has-own": "off", // TODO: enable once we drop ESLint v7 support
"prefer-promise-reject-errors": "error",
"prefer-regex-literals": "error",
quotes: ["error", "double", { avoidEscape: true }],
Expand Down
6 changes: 3 additions & 3 deletions package.json
Expand Up @@ -53,9 +53,9 @@
"vue-eslint-parser": "^8.3.0"
},
"devDependencies": {
"@eslint/eslintrc": "^0.4.3",
"@eslint/eslintrc": "^1.3.3",
"@eslint-community/eslint-plugin-mysticatea": "file:.",
"eslint": "~7.32.0",
"eslint": "~8.25.0",
"globals": "^13.17.0",
"mocha": "^9.2.2",
"npm-run-all": "^4.1.5",
Expand All @@ -65,7 +65,7 @@
"typescript": "^4.8.4"
},
"peerDependencies": {
"eslint": ">=6.6.0"
"eslint": "^6.6.0 || ^7.0.0 || ^8.0.0"
},
"engines": {
"node": "^12.22.0 || ^14.17.0 || >=16.0.0"
Expand Down
12 changes: 7 additions & 5 deletions tests/lib/configs/_rules.js
Expand Up @@ -6,13 +6,12 @@

const { Linter } = require("eslint")
const {
ConfigArrayFactory,
} = require("@eslint/eslintrc/lib/config-array-factory")
const Validator = require("eslint/lib/shared/config-validator")
const { rules: removedRules } = require("eslint/conf/replacements.json")
Legacy: { ConfigArrayFactory, ConfigValidator },
} = require("@eslint/eslintrc")
const {
rules: PluginRulesIndex,
} = require("@eslint-community/eslint-plugin-mysticatea")
const { rules: removedRules } = require("./eslint-replacements.json")

const coreRules = new Linter().getRules()
const pluginRules = new Map(
Expand All @@ -31,6 +30,7 @@ const deprecatedRuleNames = new Set(
const removedRuleNames = new Set(Object.keys(removedRules))

const configFactory = new ConfigArrayFactory()
const configValidator = new ConfigValidator()

module.exports = {
/**
Expand All @@ -40,7 +40,9 @@ 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
22 changes: 22 additions & 0 deletions tests/lib/configs/eslint-replacements.json
@@ -0,0 +1,22 @@
{
"rules": {
"generator-star": ["generator-star-spacing"],
"global-strict": ["strict"],
"no-arrow-condition": ["no-confusing-arrow", "no-constant-condition"],
"no-comma-dangle": ["comma-dangle"],
"no-empty-class": ["no-empty-character-class"],
"no-empty-label": ["no-labels"],
"no-extra-strict": ["strict"],
"no-reserved-keys": ["quote-props"],
"no-space-before-semi": ["semi-spacing"],
"no-wrap-func": ["no-extra-parens"],
"space-after-function-name": ["space-before-function-paren"],
"space-after-keywords": ["keyword-spacing"],
"space-before-function-parentheses": ["space-before-function-paren"],
"space-before-keywords": ["keyword-spacing"],
"space-in-brackets": ["object-curly-spacing", "array-bracket-spacing", "computed-property-spacing"],
"space-return-throw-case": ["keyword-spacing"],
"space-unary-word-ops": ["space-unary-ops"],
"spaced-line-comment": ["spaced-comment"]
}
}

0 comments on commit 3640662

Please sign in to comment.