From 661b57c731b370353bfc8ca5725954cfd6dc5967 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C3=ABl=20De=20Boey?= Date: Tue, 30 Nov 2021 14:00:06 +0100 Subject: [PATCH 1/7] chore(CI): simplify testing strategy --- .github/workflows/CI.yml | 26 ++++++++++++++++++++------ 1 file changed, 20 insertions(+), 6 deletions(-) diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index 1d61214..0c4bc15 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -10,21 +10,35 @@ on: jobs: test: name: Test - runs-on: ubuntu-latest strategy: matrix: - node: [12.x, 10.x, 8.x] + os: [ubuntu-latest] + eslint: [6] + node: [8, 10, 12, 14, 16, 18] + include: + # On other platforms + - os: windows-latest + node: 18 + - os: macos-latest + node: 18 + # On the minimum supported ESLint/Node.js version + - eslint: 6.6.0 + node: 8.10.0 + + runs-on: ${{ matrix.os }} steps: - name: Checkout - uses: actions/checkout@v1 - with: - fetch-depth: 1 + uses: actions/checkout@v3 - name: Install Node.js ${{ matrix.node }} - uses: actions/setup-node@v1 + uses: actions/setup-node@v3 with: node-version: ${{ matrix.node }} - name: Install Packages run: npm install + env: + CI: true + - name: Install ESLint@${{ matrix.eslint }} + run: npm install eslint@${{ matrix.eslint }} - name: Test run: npm test - name: Send Coverage From 7a4769f1e4ff31a79754abaa327e15092f2c8341 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C3=ABl=20De=20Boey?= Date: Tue, 30 Nov 2021 18:04:44 +0100 Subject: [PATCH 2/7] feat: drop Node 8 & 10 support BREAKING CHANGE: Requires Node@^12.22.0 || ^14.17.0 || >=16.0.0 --- .github/workflows/CI.yml | 4 ++-- README.md | 4 ++-- package.json | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index 0c4bc15..c0d188f 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -14,7 +14,7 @@ jobs: matrix: os: [ubuntu-latest] eslint: [6] - node: [8, 10, 12, 14, 16, 18] + node: [12.22.0, 12, 14.17.0, 14, 16, 18] include: # On other platforms - os: windows-latest @@ -23,7 +23,7 @@ jobs: node: 18 # On the minimum supported ESLint/Node.js version - eslint: 6.6.0 - node: 8.10.0 + node: 12.22.0 runs-on: ${{ matrix.os }} steps: diff --git a/README.md b/README.md index 2d9263c..a9262ad 100644 --- a/README.md +++ b/README.md @@ -16,8 +16,8 @@ npm install --save-dev eslint @mysticatea/eslint-plugin ### Requirements -- Node.js `^8.10.0` or newer versions. -- ESLint `^6.3.0` or newer versions. +- Node.js `^12.22.0 || ^14.17.0 || >=16.0.0` or newer versions. +- ESLint `^6.6.0` or newer versions. ## 📖 Usage diff --git a/package.json b/package.json index 65aad32..9ed52ee 100644 --- a/package.json +++ b/package.json @@ -3,7 +3,7 @@ "version": "13.0.0", "description": "Additional ESLint rules.", "engines": { - "node": ">=8.10.0" + "node": "^12.22.0 || ^14.17.0 || >=16.0.0" }, "main": "index.js", "files": [ From 4d7736bf177aa5630e6110320a82b5b446c3e42f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C3=ABl=20De=20Boey?= Date: Tue, 30 Nov 2021 14:39:55 +0100 Subject: [PATCH 3/7] chore: update dependencies to latest minor version --- package.json | 33 ++++++++++++++++----------------- 1 file changed, 16 insertions(+), 17 deletions(-) diff --git a/package.json b/package.json index 65aad32..98e6d9b 100644 --- a/package.json +++ b/package.json @@ -13,28 +13,27 @@ "eslint": ">=6.6.0" }, "dependencies": { - "@typescript-eslint/eslint-plugin": "~2.6.1", - "@typescript-eslint/parser": "~2.6.1", - "eslint-plugin-eslint-comments": "~3.1.2", - "eslint-plugin-eslint-plugin": "~2.1.0", - "eslint-plugin-node": "~10.0.0", - "eslint-plugin-prettier": "~3.1.1", - "eslint-plugin-vue": "~6.0.0", - "prettier": "~1.19.1", - "vue-eslint-parser": "^7.0.0" + "@typescript-eslint/eslint-plugin": "^2.34.0", + "@typescript-eslint/parser": "^2.34.0", + "eslint-plugin-eslint-comments": "^3.2.0", + "eslint-plugin-eslint-plugin": "^2.3.0", + "eslint-plugin-node": "^10.0.0", + "eslint-plugin-prettier": "^3.4.1", + "eslint-plugin-vue": "^6.2.2", + "prettier": "^1.19.1", + "vue-eslint-parser": "^7.11.0" }, "devDependencies": { "@mysticatea/eslint-plugin": "file:.", - "codecov": "^3.6.1", - "eslint": "~6.6.0", - "fs-extra": "^8.1.0", - "globals": "^12.1.1", - "mocha": "^6.2.2", + "codecov": "^3.8.3", + "eslint": "^6.8.0", + "globals": "^12.4.0", + "mocha": "^6.2.3", "npm-run-all": "^4.1.5", "nyc": "^14.1.1", - "opener": "^1.5.1", - "rimraf": "^3.0.0", - "typescript": "~3.7.2" + "opener": "^1.5.2", + "rimraf": "^3.0.2", + "typescript": "^3.9.10" }, "scripts": { "clean": "rimraf .nyc_output coverage", From 274c9a5d11568e75f5fd0a64db9f0edf1735734b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C3=ABl=20De=20Boey?= Date: Sat, 18 Dec 2021 03:25:08 +0100 Subject: [PATCH 4/7] chore: fix ESLint errors --- lib/rules/no-literal-call.js | 2 +- lib/rules/no-this-in-static.js | 2 +- lib/rules/no-use-ignored-vars.js | 2 +- lib/rules/no-useless-rest-spread.js | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/rules/no-literal-call.js b/lib/rules/no-literal-call.js index 22e6856..a6973dd 100644 --- a/lib/rules/no-literal-call.js +++ b/lib/rules/no-literal-call.js @@ -18,7 +18,7 @@ const LITERAL_AND_CLASS_TYPE = /^(?:(?:Array|Class|Object)Expression|(?:Template module.exports = { meta: { docs: { - description: "Disallow a call of a literal.", + description: "disallow a call of a literal.", category: "Possible Errors", recommended: false, url: diff --git a/lib/rules/no-this-in-static.js b/lib/rules/no-this-in-static.js index a6a342f..0f6f5cf 100644 --- a/lib/rules/no-this-in-static.js +++ b/lib/rules/no-this-in-static.js @@ -12,7 +12,7 @@ module.exports = { meta: { docs: { - description: "Disallow `this`/`super` in static methods", + description: "disallow `this`/`super` in static methods", category: "Best Practices", url: "https://github.com/mysticatea/eslint-plugin/blob/v13.0.0/docs/rules/no-this-in-static.md", diff --git a/lib/rules/no-use-ignored-vars.js b/lib/rules/no-use-ignored-vars.js index 5a4855b..e69e24b 100644 --- a/lib/rules/no-use-ignored-vars.js +++ b/lib/rules/no-use-ignored-vars.js @@ -17,7 +17,7 @@ const DEFAULT_IGNORE_PATTERN = /^_[a-zA-Z]+$/u module.exports = { meta: { docs: { - description: "Disallow a use of ignored variables.", + description: "disallow a use of ignored variables.", category: "Stylistic Issues", recommended: false, url: diff --git a/lib/rules/no-useless-rest-spread.js b/lib/rules/no-useless-rest-spread.js index ccca71b..e85c6ca 100644 --- a/lib/rules/no-useless-rest-spread.js +++ b/lib/rules/no-useless-rest-spread.js @@ -94,7 +94,7 @@ function defineFixer(sourceCode, node) { module.exports = { meta: { docs: { - description: "Disallow unnecessary spread operators.", + description: "disallow unnecessary spread operators.", category: "Best Practices", recommended: false, url: From 7ab3eaf92a84af05e42a41e2a111bce2ed0e27f2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C3=ABl=20De=20Boey?= Date: Sat, 18 Dec 2021 03:13:06 +0100 Subject: [PATCH 5/7] feat: update configs --- lib/configs/+eslint-plugin.js | 4 +++ lib/configs/_base.js | 6 +++++ lib/configs/_override-ts.js | 46 +++++++++++++++++++++++++++++------ lib/configs/_override-vue.js | 14 +++++++++++ 4 files changed, 63 insertions(+), 7 deletions(-) diff --git a/lib/configs/+eslint-plugin.js b/lib/configs/+eslint-plugin.js index 1241df1..d39bef6 100644 --- a/lib/configs/+eslint-plugin.js +++ b/lib/configs/+eslint-plugin.js @@ -34,6 +34,7 @@ module.exports = { "@mysticatea/eslint-plugin/no-missing-placeholders": "error", "@mysticatea/eslint-plugin/no-unused-placeholders": "error", "@mysticatea/eslint-plugin/no-useless-token-range": "error", + "@mysticatea/eslint-plugin/prefer-object-rule": "error", "@mysticatea/eslint-plugin/prefer-output-null": "error", "@mysticatea/eslint-plugin/prefer-placeholders": "error", "@mysticatea/eslint-plugin/prefer-replace-text": "error", @@ -41,11 +42,14 @@ module.exports = { "error", "[^a-z'\"{].*\\.$", ], + "@mysticatea/eslint-plugin/require-meta-docs-description": + "error", "@mysticatea/eslint-plugin/require-meta-docs-url": [ "error", { pattern: rulesDocumentUrl }, ], "@mysticatea/eslint-plugin/require-meta-fixable": "error", + "@mysticatea/eslint-plugin/require-meta-schema": "error", "@mysticatea/eslint-plugin/require-meta-type": "error", "@mysticatea/eslint-plugin/test-case-property-ordering": [ "error", diff --git a/lib/configs/_base.js b/lib/configs/_base.js index 4a21337..7708e61 100644 --- a/lib/configs/_base.js +++ b/lib/configs/_base.js @@ -33,6 +33,7 @@ module.exports = { "for-direction": "error", "func-style": ["error", "declaration"], "getter-return": "error", + "grouped-accessor-pairs": "error", "init-declarations": "error", "linebreak-style": ["error", "unix"], "lines-between-class-members": "error", @@ -47,11 +48,13 @@ module.exports = { "no-compare-neg-zero": "error", "no-cond-assign": "error", "no-constant-condition": "error", + "no-constructor-return": "error", "no-control-regex": "error", "no-debugger": "error", "no-delete-var": "error", "no-div-regex": "error", "no-dupe-args": "error", + "no-dupe-else-if": "error", "no-dupe-keys": "error", "no-duplicate-case": "error", "no-else-return": "error", @@ -128,6 +131,7 @@ module.exports = { "no-self-assign": ["error", { props: true }], "no-self-compare": "error", "no-sequences": "error", + "no-setter-return": "error", "no-shadow": ["error", { builtinGlobals: true }], "no-shadow-restricted-names": "error", "no-sparse-arrays": "error", @@ -173,6 +177,7 @@ module.exports = { { blankLine: "always", next: "function", prev: "*" }, { blankLine: "always", next: "*", prev: "function" }, ], + "prefer-exponentiation-operator": "error", "prefer-promise-reject-errors": "error", "prefer-regex-literals": "error", quotes: ["error", "double", { avoidEscape: true }], @@ -387,6 +392,7 @@ module.exports = { ], }, ], + "@mysticatea/eslint-comments/require-description": "off", // prettier "@mysticatea/prettier": [ diff --git a/lib/configs/_override-ts.js b/lib/configs/_override-ts.js index 3b94d9a..900e37c 100644 --- a/lib/configs/_override-ts.js +++ b/lib/configs/_override-ts.js @@ -19,40 +19,75 @@ module.exports = { "@mysticatea/ts/adjacent-overload-signatures": "error", "@mysticatea/ts/array-type": "error", "@mysticatea/ts/await-thenable": "error", - "@mysticatea/ts/ban-ts-ignore": "error", - "@mysticatea/ts/class-name-casing": "error", + "@mysticatea/ts/ban-ts-comment": "error", + "@mysticatea/ts/class-literal-property-style": "error", + "@mysticatea/ts/comma-spacing": "error", "@mysticatea/ts/consistent-type-assertions": "error", + "@mysticatea/ts/default-param-last": "error", + "@mysticatea/ts/dot-notation": "error", "@mysticatea/ts/explicit-member-accessibility": "error", - "@mysticatea/ts/interface-name-prefix": "error", - "@mysticatea/ts/member-naming": "error", + "@mysticatea/ts/explicit-module-boundary-types": "error", + "@mysticatea/ts/init-declarations": "error", + "@mysticatea/ts/keyword-spacing": "error", + "@mysticatea/ts/lines-between-class-members": "error", + "@mysticatea/ts/method-signature-style": "error", + "@mysticatea/ts/naming-convention": "error", "@mysticatea/ts/no-array-constructor": "error", + "@mysticatea/ts/no-base-to-string": "error", + "@mysticatea/ts/no-dupe-class-members": "error", + "@mysticatea/ts/no-dynamic-delete": "error", "@mysticatea/ts/no-empty-interface": "error", + "@mysticatea/ts/no-extra-non-null-assertion": "error", + "@mysticatea/ts/no-extra-semi": "error", "@mysticatea/ts/no-extraneous-class": "error", "@mysticatea/ts/no-floating-promises": "error", "@mysticatea/ts/no-for-in-array": "error", + "@mysticatea/ts/no-implied-eval": "error", "@mysticatea/ts/no-inferrable-types": "error", + "@mysticatea/ts/no-invalid-this": "error", + "@mysticatea/ts/no-invalid-void-type": "error", "@mysticatea/ts/no-misused-new": "error", "@mysticatea/ts/no-misused-promises": "error", + "@mysticatea/ts/no-non-null-asserted-optional-chain": "error", "@mysticatea/ts/no-parameter-properties": "error", "@mysticatea/ts/no-require-imports": "error", "@mysticatea/ts/no-this-alias": [ "error", { allowDestructuring: true }, ], + "@mysticatea/ts/no-throw-literal": "error", + "@mysticatea/ts/no-unnecessary-boolean-literal-compare": + "error", "@mysticatea/ts/no-unnecessary-qualifier": "error", "@mysticatea/ts/no-unnecessary-type-arguments": "error", "@mysticatea/ts/no-unnecessary-type-assertion": "error", + "@mysticatea/ts/no-unsafe-assignment": "error", + "@mysticatea/ts/no-unsafe-call": "error", + "@mysticatea/ts/no-unsafe-member-access": "error", + "@mysticatea/ts/no-unsafe-return": "error", + "@mysticatea/ts/no-unused-expressions": "error", + "@mysticatea/ts/no-unused-vars-experimental": "error", "@mysticatea/ts/no-var-requires": "error", + "@mysticatea/ts/prefer-as-const": "error", // https://github.com/typescript-eslint/typescript-eslint/issues/454 "@mysticatea/ts/prefer-function-type": "off", "@mysticatea/ts/prefer-includes": "error", "@mysticatea/ts/prefer-namespace-keyword": "error", + "@mysticatea/ts/prefer-nullish-coalescing": "error", + "@mysticatea/ts/prefer-optional-chain": "error", + "@mysticatea/ts/prefer-readonly-parameter-types": "error", // https://github.com/typescript-eslint/typescript-eslint/issues/946 "@mysticatea/ts/prefer-readonly": "off", + "@mysticatea/ts/prefer-reduce-type-parameter": "off", "@mysticatea/ts/prefer-regexp-exec": "error", "@mysticatea/ts/prefer-string-starts-ends-with": "error", + "@mysticatea/ts/prefer-ts-expect-error": "off", "@mysticatea/ts/restrict-plus-operands": "error", "@mysticatea/ts/require-array-sort-compare": "error", + "@mysticatea/ts/restrict-template-expressions": "error", + "@mysticatea/ts/return-await": "error", + "@mysticatea/ts/space-before-function-paren": "error", + "@mysticatea/ts/switch-exhaustiveness-check": "error", "@mysticatea/ts/triple-slash-reference": "error", // ăȘんかèȘ€æ€œçŸ„ăŒć€šă„... "@mysticatea/ts/unbound-method": [ @@ -75,8 +110,6 @@ module.exports = { ], // Replacements - camelcase: "off", - "@mysticatea/ts/camelcase": "error", "no-empty-function": "off", "@mysticatea/ts/no-empty-function": "error", "no-useless-constructor": "off", @@ -101,7 +134,6 @@ module.exports = { "@mysticatea/ts/consistent-type-definitions": "off", "@mysticatea/ts/explicit-function-return-type": "off", // I want but this is not so... "@mysticatea/ts/func-call-spacing": "off", // favor of Prettier. - "@mysticatea/ts/generic-type-naming": "off", "@mysticatea/ts/indent": "off", // favor of Prettier. "@mysticatea/ts/member-delimiter-style": "off", // favor of Prettier. "@mysticatea/ts/member-ordering": "off", diff --git a/lib/configs/_override-vue.js b/lib/configs/_override-vue.js index 9d38f11..005f32e 100644 --- a/lib/configs/_override-vue.js +++ b/lib/configs/_override-vue.js @@ -31,6 +31,8 @@ module.exports = { }, ], "@mysticatea/vue/comment-directive": "error", + "@mysticatea/vue/component-definition-name-casing": "error", + "@mysticatea/vue/component-tags-order": "error", "@mysticatea/vue/dot-location": "error", "@mysticatea/vue/eqeqeq": [ "error", @@ -51,32 +53,44 @@ module.exports = { }, }, ], + "@mysticatea/vue/max-len": ["error", { tabWidth: 4 }], "@mysticatea/vue/no-async-in-computed-properties": "error", "@mysticatea/vue/no-boolean-default": "error", "@mysticatea/vue/no-deprecated-scope-attribute": "error", + "@mysticatea/vue/no-deprecated-slot-attribute": "error", + "@mysticatea/vue/no-deprecated-slot-scope-attribute": "error", "@mysticatea/vue/no-dupe-keys": "error", "@mysticatea/vue/no-duplicate-attributes": "error", "@mysticatea/vue/no-empty-pattern": "error", + "@mysticatea/vue/no-irregular-whitespace": "error", "@mysticatea/vue/no-parsing-error": "error", + "@mysticatea/vue/no-reserved-component-names": "error", "@mysticatea/vue/no-reserved-keys": "error", "@mysticatea/vue/no-shared-component-data": "error", "@mysticatea/vue/no-side-effects-in-computed-properties": "error", + "@mysticatea/vue/no-static-inline-styles": "error", "@mysticatea/vue/no-template-key": "error", "@mysticatea/vue/no-textarea-mustache": "error", + "@mysticatea/vue/no-unsupported-features": "error", "@mysticatea/vue/no-unused-vars": "error", "@mysticatea/vue/object-curly-spacing": ["error", "always"], + "@mysticatea/vue/padding-line-between-blocks": "error", "@mysticatea/vue/require-component-is": "error", "@mysticatea/vue/require-direct-export": "error", + "@mysticatea/vue/require-name-property": "error", "@mysticatea/vue/require-render-return": "error", "@mysticatea/vue/require-v-for-key": "error", "@mysticatea/vue/require-valid-default-prop": "error", "@mysticatea/vue/return-in-computed-property": "error", + "@mysticatea/vue/sort-keys": "error", "@mysticatea/vue/space-infix-ops": "error", "@mysticatea/vue/space-unary-ops": "error", + "@mysticatea/vue/static-class-names-order": "error", "@mysticatea/vue/v-on-function-call": "error", "@mysticatea/vue/v-slot-style": "error", "@mysticatea/vue/valid-template-root": "error", + "@mysticatea/vue/valid-v-bind-sync": "error", "@mysticatea/vue/valid-v-bind": "error", "@mysticatea/vue/valid-v-cloak": "error", "@mysticatea/vue/valid-v-else-if": "error", From 54ad8c7c44285e8692041c207b77fe404d5d30c2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C3=ABl=20De=20Boey?= Date: Sat, 18 Dec 2021 05:16:35 +0100 Subject: [PATCH 6/7] feat: update `eslint-plugin-eslint-plugin` + update configs --- lib/configs/+eslint-plugin.js | 4 ++++ package.json | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/configs/+eslint-plugin.js b/lib/configs/+eslint-plugin.js index d39bef6..6de2e61 100644 --- a/lib/configs/+eslint-plugin.js +++ b/lib/configs/+eslint-plugin.js @@ -32,8 +32,10 @@ module.exports = { "@mysticatea/eslint-plugin/no-deprecated-report-api": "error", "@mysticatea/eslint-plugin/no-identical-tests": "error", "@mysticatea/eslint-plugin/no-missing-placeholders": "error", + "@mysticatea/eslint-plugin/no-only-tests": "error", "@mysticatea/eslint-plugin/no-unused-placeholders": "error", "@mysticatea/eslint-plugin/no-useless-token-range": "error", + "@mysticatea/eslint-plugin/prefer-message-ids": "error", "@mysticatea/eslint-plugin/prefer-object-rule": "error", "@mysticatea/eslint-plugin/prefer-output-null": "error", "@mysticatea/eslint-plugin/prefer-placeholders": "error", @@ -49,6 +51,8 @@ module.exports = { { pattern: rulesDocumentUrl }, ], "@mysticatea/eslint-plugin/require-meta-fixable": "error", + "@mysticatea/eslint-plugin/require-meta-has-suggestions": + "error", "@mysticatea/eslint-plugin/require-meta-schema": "error", "@mysticatea/eslint-plugin/require-meta-type": "error", "@mysticatea/eslint-plugin/test-case-property-ordering": [ diff --git a/package.json b/package.json index 99120dd..0377ad1 100644 --- a/package.json +++ b/package.json @@ -16,7 +16,7 @@ "@typescript-eslint/eslint-plugin": "^2.34.0", "@typescript-eslint/parser": "^2.34.0", "eslint-plugin-eslint-comments": "^3.2.0", - "eslint-plugin-eslint-plugin": "^2.3.0", + "eslint-plugin-eslint-plugin": "^3.6.1", "eslint-plugin-node": "^10.0.0", "eslint-plugin-prettier": "^3.4.1", "eslint-plugin-vue": "^6.2.2", From 5d387eb05c842478598bd8d80db9515bb6bdc88f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C3=ABl=20De=20Boey?= Date: Sat, 18 Dec 2021 06:21:30 +0100 Subject: [PATCH 7/7] chore: fix ESLint errors --- lib/rules/arrow-parens.js | 12 ++++++++---- lib/rules/block-scoped-var.js | 16 +++++++++++----- lib/rules/no-instanceof-array.js | 7 +++++-- lib/rules/no-instanceof-wrapper.js | 7 +++++-- lib/rules/no-literal-call.js | 5 ++++- lib/rules/no-this-in-static.js | 5 ++++- lib/rules/no-use-ignored-vars.js | 7 +++++-- lib/rules/no-useless-rest-spread.js | 5 ++++- lib/rules/prefer-for-of.js | 10 ++++++---- 9 files changed, 52 insertions(+), 22 deletions(-) diff --git a/lib/rules/arrow-parens.js b/lib/rules/arrow-parens.js index 3736763..89f3a8e 100644 --- a/lib/rules/arrow-parens.js +++ b/lib/rules/arrow-parens.js @@ -34,6 +34,12 @@ module.exports = { "https://github.com/mysticatea/eslint-plugin/blob/v13.0.0/docs/rules/arrow-parens.md", }, fixable: "code", + messages: { + expectedParentheses: + "Expected to enclose this argument with parentheses.", + unexpectedParentheses: + "Unexpected parentheses enclosing this argument.", + }, schema: [], type: "suggestion", }, @@ -54,8 +60,7 @@ module.exports = { ) { context.report({ node, - message: - "Unexpected parentheses enclosing this argument.", + messageId: "unexpectedParentheses", fix(fixer) { const id = node.params[0] const begin = first.range[0] @@ -73,8 +78,7 @@ module.exports = { } else if (!isOpenParen(before) || !isSameLine(before, first)) { context.report({ node, - message: - "Expected to enclose this argument with parentheses.", + messageId: "expectedParentheses", fix(fixer) { const id = node.params[0] diff --git a/lib/rules/block-scoped-var.js b/lib/rules/block-scoped-var.js index b212809..0b8a0cf 100644 --- a/lib/rules/block-scoped-var.js +++ b/lib/rules/block-scoped-var.js @@ -200,6 +200,13 @@ module.exports = { "https://github.com/mysticatea/eslint-plugin/blob/v13.0.0/docs/rules/block-scoped-var.md", }, fixable: null, + messages: { + alreadyDefined: '"{{name}}" is already defined.', + definedInUpperScope: + '"{{name}}" is already defined in the upper scope.', + undefined: '"{{name}}" is not defined.', + unused: '"{{name}}" is defined but never used.', + }, schema: [], type: "suggestion", }, @@ -244,7 +251,7 @@ module.exports = { if (scope == null) { context.report({ node: reference.identifier, - message: '"{{name}}" is not defined.', + messageId: "undefined", data: { name: reference.identifier.name }, }) } @@ -255,7 +262,7 @@ module.exports = { for (const identifier of scope.redeclarations) { context.report({ node: identifier, - message: '"{{name}}" is already defined.', + messageId: "alreadyDefined", data: { name: identifier.name }, }) } @@ -263,8 +270,7 @@ module.exports = { if (scope.shadowing) { context.report({ node: scope.identifier, - message: - '"{{name}}" is already defined in the upper scope.', + messageId: "definedInUpperScope", data: { name: scope.identifier.name }, }) } @@ -272,7 +278,7 @@ module.exports = { if (hasReadRef && !scope.used) { context.report({ node: scope.identifier, - message: '"{{name}}" is defined but never used.', + messageId: "unused", data: { name: scope.identifier.name }, }) } diff --git a/lib/rules/no-instanceof-array.js b/lib/rules/no-instanceof-array.js index 5cc1e54..1bcdf15 100644 --- a/lib/rules/no-instanceof-array.js +++ b/lib/rules/no-instanceof-array.js @@ -18,6 +18,10 @@ module.exports = { "https://github.com/mysticatea/eslint-plugin/blob/v13.0.0/docs/rules/no-instanceof-array.md", }, fixable: "code", + messages: { + noInstanceofArray: + "Unexpected 'instanceof' operator. Use 'Array.isArray' instead.", + }, schema: [], type: "problem", }, @@ -62,8 +66,7 @@ module.exports = { context.report({ node, loc: node.loc, - message: - "Unexpected 'instanceof' operator. Use 'Array.isArray' instead.", + messageId: "noInstanceofArray", fix: fixer => fixer.replaceText( node, diff --git a/lib/rules/no-instanceof-wrapper.js b/lib/rules/no-instanceof-wrapper.js index c30ee6b..44da0cb 100644 --- a/lib/rules/no-instanceof-wrapper.js +++ b/lib/rules/no-instanceof-wrapper.js @@ -18,6 +18,10 @@ module.exports = { "https://github.com/mysticatea/eslint-plugin/blob/v13.0.0/docs/rules/no-instanceof-wrapper.md", }, fixable: "code", + messages: { + noInstanceofWrapper: + "Unexpected 'instanceof' operator. Use 'typeof x === \"{{typeName}}\"' instead.", + }, schema: [], type: "problem", }, @@ -73,8 +77,7 @@ module.exports = { context.report({ node, loc: node.loc, - message: - "Unexpected 'instanceof' operator. Use 'typeof x === \"{{typeName}}\"' instead.", + messageId: "noInstanceofWrapper", data: { typeName }, fix: fixer => fixer.replaceText( diff --git a/lib/rules/no-literal-call.js b/lib/rules/no-literal-call.js index a6973dd..14f4636 100644 --- a/lib/rules/no-literal-call.js +++ b/lib/rules/no-literal-call.js @@ -25,6 +25,9 @@ module.exports = { "https://github.com/mysticatea/eslint-plugin/blob/v13.0.0/docs/rules/no-literal-call.md", }, fixable: null, + messages: { + noLiteralCall: "This is not a function.", + }, schema: [], type: "problem", }, @@ -41,7 +44,7 @@ module.exports = { if (pattern.test(callee.type)) { context.report({ node: callee, - message: "This is not a function.", + messageId: "noLiteralCall", }) } } diff --git a/lib/rules/no-this-in-static.js b/lib/rules/no-this-in-static.js index 0f6f5cf..f9477d5 100644 --- a/lib/rules/no-this-in-static.js +++ b/lib/rules/no-this-in-static.js @@ -18,6 +18,9 @@ module.exports = { "https://github.com/mysticatea/eslint-plugin/blob/v13.0.0/docs/rules/no-this-in-static.md", }, fixable: null, + messages: { + noThisInStatic: "Unexpected '{{type}}'.", + }, schema: [], type: "suggestion", }, @@ -73,7 +76,7 @@ module.exports = { context.report({ node, loc: node.loc, - message: "Unexpected '{{type}}'.", + messageId: "noThisInStatic", data: { type: sourceCode.getText(node) }, }) } diff --git a/lib/rules/no-use-ignored-vars.js b/lib/rules/no-use-ignored-vars.js index e69e24b..582cace 100644 --- a/lib/rules/no-use-ignored-vars.js +++ b/lib/rules/no-use-ignored-vars.js @@ -24,6 +24,10 @@ module.exports = { "https://github.com/mysticatea/eslint-plugin/blob/v13.0.0/docs/rules/no-use-ignored-vars.md", }, fixable: null, + messages: { + noUseIgnoredVars: + "Unexpected a use of '{{name}}'. This name is matched to ignored pattern.", + }, schema: [{ type: "string" }], type: "suggestion", }, @@ -65,8 +69,7 @@ module.exports = { context.report({ node: id, - message: - "Unexpected a use of '{{name}}'. This name is matched to ignored pattern.", + messageId: "noUseIgnoredVars", data: id, }) } diff --git a/lib/rules/no-useless-rest-spread.js b/lib/rules/no-useless-rest-spread.js index e85c6ca..5c6cbc8 100644 --- a/lib/rules/no-useless-rest-spread.js +++ b/lib/rules/no-useless-rest-spread.js @@ -101,6 +101,9 @@ module.exports = { "https://github.com/mysticatea/eslint-plugin/blob/v13.0.0/docs/rules/no-useless-rest-spread.md", }, fixable: "code", + messages: { + noUselessRestSpread: "Redundant {{type1}} {{type2}}.", + }, schema: [], type: "suggestion", }, @@ -139,7 +142,7 @@ module.exports = { context.report({ node, - message: "Redundant {{type1}} {{type2}}.", + messageId: "noUselessRestSpread", data: { type1, type2 }, fix: defineFixer(sourceCode, node), }) diff --git a/lib/rules/prefer-for-of.js b/lib/rules/prefer-for-of.js index 37ea4e6..81dc4e7 100644 --- a/lib/rules/prefer-for-of.js +++ b/lib/rules/prefer-for-of.js @@ -16,7 +16,6 @@ const assert = require("assert") //------------------------------------------------------------------------------ const SENTINEL_TYPE = /(?:Declaration|Statement)$/u -const MESSAGE = "Expected for-of statement." /** * Checks whether the given outer node contains the given inner node. @@ -501,6 +500,9 @@ module.exports = { "https://github.com/mysticatea/eslint-plugin/blob/v13.0.0/docs/rules/prefer-for-of.md", }, fixable: "code", + messages: { + preferForOf: "Expected for-of statement.", + }, schema: [], type: "suggestion", }, @@ -547,7 +549,7 @@ module.exports = { const expressionStatementNode = funcInfo.node.parent.parent context.report({ node: expressionStatementNode, - message: MESSAGE, + messageId: "preferForOf", fix: fixArrayForEach.bind(null, context, funcInfo), }) } @@ -609,14 +611,14 @@ module.exports = { ) { context.report({ node, - message: MESSAGE, + messageId: "preferForOf", fix: fixForStatement.bind(null, context, node), }) } }, ForInStatement(node) { - context.report({ node, message: MESSAGE }) + context.report({ node, messageId: "preferForOf" }) }, } },