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 01/17] 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 02/17] 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 03/17] 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 04/17] 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 05/17] 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 a0fe10023573802fcb44f7eaaa755004d348e2c9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C3=ABl=20De=20Boey?= Date: Sat, 18 Dec 2021 04:09:46 +0100 Subject: [PATCH 06/17] chore: update dependencies (Node v12) --- package.json | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/package.json b/package.json index 99120dd..d764c08 100644 --- a/package.json +++ b/package.json @@ -28,12 +28,12 @@ "codecov": "^3.8.3", "eslint": "^6.8.0", "globals": "^12.4.0", - "mocha": "^6.2.3", + "mocha": "^9.2.2", "npm-run-all": "^4.1.5", - "nyc": "^14.1.1", + "nyc": "^15.1.0", "opener": "^1.5.2", "rimraf": "^3.0.2", - "typescript": "^3.9.10" + "typescript": "^4.8.3" }, "scripts": { "clean": "rimraf .nyc_output coverage", From 6f956a4db10b05444dc3e62d91c2712b2b2e505a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C3=ABl=20De=20Boey?= Date: Sat, 18 Dec 2021 04:21:55 +0100 Subject: [PATCH 07/17] feat: update `globals` + update configs --- lib/configs/_browser-globals.js | 20 +++++++++++++++++++- package.json | 2 +- 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/lib/configs/_browser-globals.js b/lib/configs/_browser-globals.js index e4cba16..8b830da 100644 --- a/lib/configs/_browser-globals.js +++ b/lib/configs/_browser-globals.js @@ -1,4 +1,6 @@ +// // DON'T EDIT THIS FILE WHICH WAS GENERATED BY './scripts/generate-browser-globals.js'. +// "use strict" module.exports = { @@ -25,7 +27,7 @@ module.exports = { AudioParam: "readonly", AudioProcessingEvent: "readonly", AudioScheduledSourceNode: "readonly", - "AudioWorkletGlobalScope ": "readonly", + AudioWorkletGlobalScope: "readonly", AudioWorkletNode: "readonly", AudioWorkletProcessor: "readonly", BarProp: "readonly", @@ -45,15 +47,24 @@ module.exports = { CSSImportRule: "readonly", CSSKeyframeRule: "readonly", CSSKeyframesRule: "readonly", + CSSMatrixComponent: "readonly", CSSMediaRule: "readonly", CSSNamespaceRule: "readonly", CSSPageRule: "readonly", + CSSPerspective: "readonly", + CSSRotate: "readonly", CSSRule: "readonly", CSSRuleList: "readonly", + CSSScale: "readonly", + CSSSkew: "readonly", + CSSSkewX: "readonly", + CSSSkewY: "readonly", CSSStyleDeclaration: "readonly", CSSStyleRule: "readonly", CSSStyleSheet: "readonly", CSSSupportsRule: "readonly", + CSSTransformValue: "readonly", + CSSTranslate: "readonly", Cache: "readonly", CacheStorage: "readonly", CanvasCaptureMediaStreamTrack: "readonly", @@ -86,6 +97,7 @@ module.exports = { DOMPointReadOnly: "readonly", DOMQuad: "readonly", DOMRect: "readonly", + DOMRectList: "readonly", DOMRectReadOnly: "readonly", DOMStringList: "readonly", DOMStringMap: "readonly", @@ -113,6 +125,7 @@ module.exports = { FontFace: "readonly", FontFaceSetLoadEvent: "readonly", FormData: "readonly", + FormDataEvent: "readonly", GainNode: "readonly", Gamepad: "readonly", GamepadButton: "readonly", @@ -242,6 +255,7 @@ module.exports = { MediaKeyStatusMap: "readonly", MediaKeySystemAccess: "readonly", MediaList: "readonly", + MediaMetadata: "readonly", MediaQueryList: "readonly", MediaQueryListEvent: "readonly", MediaRecorder: "readonly", @@ -274,8 +288,10 @@ module.exports = { OfflineAudioCompletionEvent: "readonly", OfflineAudioContext: "readonly", OffscreenCanvas: "writable", + OffscreenCanvasRenderingContext2D: "readonly", Option: "readonly", OscillatorNode: "readonly", + OverconstrainedError: "readonly", PageTransitionEvent: "readonly", PannerNode: "readonly", Path2D: "readonly", @@ -460,6 +476,7 @@ module.exports = { StorageManager: "readonly", StyleSheet: "readonly", StyleSheetList: "readonly", + SubmitEvent: "readonly", SubtleCrypto: "readonly", TaskAttributionTiming: "readonly", Text: "readonly", @@ -476,6 +493,7 @@ module.exports = { TouchEvent: "readonly", TouchList: "readonly", TrackEvent: "readonly", + TransformStream: "readonly", TransitionEvent: "readonly", TreeWalker: "readonly", UIEvent: "readonly", diff --git a/package.json b/package.json index 99120dd..cbe28de 100644 --- a/package.json +++ b/package.json @@ -27,7 +27,7 @@ "@mysticatea/eslint-plugin": "file:.", "codecov": "^3.8.3", "eslint": "^6.8.0", - "globals": "^12.4.0", + "globals": "^13.17.0", "mocha": "^6.2.3", "npm-run-all": "^4.1.5", "nyc": "^14.1.1", From 15a8f1f91759bf84b96b95adc0f40a85d236ee4b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C3=ABl=20De=20Boey?= Date: Sat, 18 Dec 2021 04:27:32 +0100 Subject: [PATCH 08/17] feat: update `prettier` --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 99120dd..a598887 100644 --- a/package.json +++ b/package.json @@ -20,7 +20,7 @@ "eslint-plugin-node": "^10.0.0", "eslint-plugin-prettier": "^3.4.1", "eslint-plugin-vue": "^6.2.2", - "prettier": "^1.19.1", + "prettier": "^2.7.1", "vue-eslint-parser": "^7.11.0" }, "devDependencies": { From 8d2f9257d54a5b37e8b11b11bcf98b0abf32aeb4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C3=ABl=20De=20Boey?= Date: Sat, 18 Dec 2021 04:28:02 +0100 Subject: [PATCH 09/17] chore: fix ESLint errors --- lib/processors/vue.js | 2 +- lib/rules/arrow-parens.js | 3 +-- lib/rules/block-scoped-var.js | 9 ++++---- lib/rules/no-instanceof-array.js | 5 ++--- lib/rules/no-instanceof-wrapper.js | 5 ++--- lib/rules/no-literal-call.js | 6 +++--- lib/rules/no-this-in-static.js | 3 +-- lib/rules/no-use-ignored-vars.js | 3 +-- lib/rules/no-useless-rest-spread.js | 10 ++++----- lib/rules/prefer-for-of.js | 10 ++++----- scripts/generate-configs.js | 6 +++--- scripts/generate-rules.js | 8 +++---- tests/lib/configs/_rules.js | 14 ++++++------ tests/lib/rules/block-scoped-var.js | 6 ++---- tests/lib/rules/prefer-for-of.js | 33 ++++++++++------------------- 15 files changed, 53 insertions(+), 70 deletions(-) diff --git a/lib/processors/vue.js b/lib/processors/vue.js index b6aa629..be211ea 100644 --- a/lib/processors/vue.js +++ b/lib/processors/vue.js @@ -22,7 +22,7 @@ module.exports = { } // Filter messages which are in disabled area. - return messages[0].filter(message => { + return messages[0].filter((message) => { if (message.ruleId === "@mysticatea/vue/comment-directive") { const rules = message.message.split(" ") const type = rules.shift() diff --git a/lib/rules/arrow-parens.js b/lib/rules/arrow-parens.js index 3736763..45bf21e 100644 --- a/lib/rules/arrow-parens.js +++ b/lib/rules/arrow-parens.js @@ -30,8 +30,7 @@ module.exports = { description: "enforce the parentheses style of arrow functions.", category: "Stylistic Issues", recommended: false, - url: - "https://github.com/mysticatea/eslint-plugin/blob/v13.0.0/docs/rules/arrow-parens.md", + url: "https://github.com/mysticatea/eslint-plugin/blob/v13.0.0/docs/rules/arrow-parens.md", }, fixable: "code", schema: [], diff --git a/lib/rules/block-scoped-var.js b/lib/rules/block-scoped-var.js index b212809..7d774ca 100644 --- a/lib/rules/block-scoped-var.js +++ b/lib/rules/block-scoped-var.js @@ -9,8 +9,10 @@ // Helpers //------------------------------------------------------------------------------ -const scopeNodeType = /^(?:(?:Block|Switch|For(?:In|Of)?)Statement|CatchClause|Program)$/u -const containerNodeType = /^(?:For(?:In|Of)?Statement|(?:Arrow)?Function(?:Declaration|Expression))$/u +const scopeNodeType = + /^(?:(?:Block|Switch|For(?:In|Of)?)Statement|CatchClause|Program)$/u +const containerNodeType = + /^(?:For(?:In|Of)?Statement|(?:Arrow)?Function(?:Declaration|Expression))$/u /** * Checks whether or not a given definition should be skipped. @@ -196,8 +198,7 @@ module.exports = { description: "disallow illegal usage of variables as block-scoped.", category: "Possible Errors", recommended: false, - url: - "https://github.com/mysticatea/eslint-plugin/blob/v13.0.0/docs/rules/block-scoped-var.md", + url: "https://github.com/mysticatea/eslint-plugin/blob/v13.0.0/docs/rules/block-scoped-var.md", }, fixable: null, schema: [], diff --git a/lib/rules/no-instanceof-array.js b/lib/rules/no-instanceof-array.js index 5cc1e54..2cb8734 100644 --- a/lib/rules/no-instanceof-array.js +++ b/lib/rules/no-instanceof-array.js @@ -14,8 +14,7 @@ module.exports = { docs: { description: "disallow 'instanceof' for Array", category: "Best Practices", - url: - "https://github.com/mysticatea/eslint-plugin/blob/v13.0.0/docs/rules/no-instanceof-array.md", + url: "https://github.com/mysticatea/eslint-plugin/blob/v13.0.0/docs/rules/no-instanceof-array.md", }, fixable: "code", schema: [], @@ -64,7 +63,7 @@ module.exports = { loc: node.loc, message: "Unexpected 'instanceof' operator. Use 'Array.isArray' instead.", - fix: fixer => + fix: (fixer) => fixer.replaceText( node, `Array.isArray(${sourceCode.getText( diff --git a/lib/rules/no-instanceof-wrapper.js b/lib/rules/no-instanceof-wrapper.js index c30ee6b..f35bf2e 100644 --- a/lib/rules/no-instanceof-wrapper.js +++ b/lib/rules/no-instanceof-wrapper.js @@ -14,8 +14,7 @@ module.exports = { docs: { description: "disallow 'instanceof' for wrapper objects", category: "Best Practices", - url: - "https://github.com/mysticatea/eslint-plugin/blob/v13.0.0/docs/rules/no-instanceof-wrapper.md", + url: "https://github.com/mysticatea/eslint-plugin/blob/v13.0.0/docs/rules/no-instanceof-wrapper.md", }, fixable: "code", schema: [], @@ -76,7 +75,7 @@ module.exports = { message: "Unexpected 'instanceof' operator. Use 'typeof x === \"{{typeName}}\"' instead.", data: { typeName }, - fix: fixer => + fix: (fixer) => fixer.replaceText( node, `typeof ${sourceCode.getText( diff --git a/lib/rules/no-literal-call.js b/lib/rules/no-literal-call.js index a6973dd..6733c5e 100644 --- a/lib/rules/no-literal-call.js +++ b/lib/rules/no-literal-call.js @@ -9,7 +9,8 @@ //------------------------------------------------------------------------------ const LITERAL_TYPE = /^(?:(?:Array|Object)Expression|(?:Template)?Literal)$/u -const LITERAL_AND_CLASS_TYPE = /^(?:(?:Array|Class|Object)Expression|(?:Template)?Literal)$/u +const LITERAL_AND_CLASS_TYPE = + /^(?:(?:Array|Class|Object)Expression|(?:Template)?Literal)$/u //------------------------------------------------------------------------------ // Rule Definition @@ -21,8 +22,7 @@ module.exports = { description: "disallow a call of a literal.", category: "Possible Errors", recommended: false, - url: - "https://github.com/mysticatea/eslint-plugin/blob/v13.0.0/docs/rules/no-literal-call.md", + url: "https://github.com/mysticatea/eslint-plugin/blob/v13.0.0/docs/rules/no-literal-call.md", }, fixable: null, schema: [], diff --git a/lib/rules/no-this-in-static.js b/lib/rules/no-this-in-static.js index 0f6f5cf..d065d21 100644 --- a/lib/rules/no-this-in-static.js +++ b/lib/rules/no-this-in-static.js @@ -14,8 +14,7 @@ module.exports = { docs: { 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", + url: "https://github.com/mysticatea/eslint-plugin/blob/v13.0.0/docs/rules/no-this-in-static.md", }, fixable: null, schema: [], diff --git a/lib/rules/no-use-ignored-vars.js b/lib/rules/no-use-ignored-vars.js index e69e24b..ec9cd12 100644 --- a/lib/rules/no-use-ignored-vars.js +++ b/lib/rules/no-use-ignored-vars.js @@ -20,8 +20,7 @@ module.exports = { description: "disallow a use of ignored variables.", category: "Stylistic Issues", recommended: false, - url: - "https://github.com/mysticatea/eslint-plugin/blob/v13.0.0/docs/rules/no-use-ignored-vars.md", + url: "https://github.com/mysticatea/eslint-plugin/blob/v13.0.0/docs/rules/no-use-ignored-vars.md", }, fixable: null, schema: [{ type: "string" }], diff --git a/lib/rules/no-useless-rest-spread.js b/lib/rules/no-useless-rest-spread.js index e85c6ca..ee6ba2b 100644 --- a/lib/rules/no-useless-rest-spread.js +++ b/lib/rules/no-useless-rest-spread.js @@ -8,7 +8,8 @@ // Helpers //------------------------------------------------------------------------------ -const FUNC_TYPE = /^(?:FunctionDeclaration|(?:New|Call|(?:Arrow)?Function)Expression)$/u +const FUNC_TYPE = + /^(?:FunctionDeclaration|(?:New|Call|(?:Arrow)?Function)Expression)$/u const PROPERTY_PATTERN = /^(?:Experimental)?(Rest|Spread)Property$/u /** @@ -56,7 +57,7 @@ function getLastElementToken(sourceCode, node) { * @returns {function} A fixer function. */ function defineFixer(sourceCode, node) { - return fixer => { + return (fixer) => { const child = node.argument // If the inner array includes holes, do nothing. @@ -97,8 +98,7 @@ module.exports = { description: "disallow unnecessary spread operators.", category: "Best Practices", recommended: false, - url: - "https://github.com/mysticatea/eslint-plugin/blob/v13.0.0/docs/rules/no-useless-rest-spread.md", + url: "https://github.com/mysticatea/eslint-plugin/blob/v13.0.0/docs/rules/no-useless-rest-spread.md", }, fixable: "code", schema: [], @@ -116,7 +116,7 @@ module.exports = { function verify(node) { const nodeType = node.type.replace( PROPERTY_PATTERN, - t => `${t}Element` + (t) => `${t}Element` ) const parentType = node.parent.type const argumentType = node.argument.type diff --git a/lib/rules/prefer-for-of.js b/lib/rules/prefer-for-of.js index 37ea4e6..d63ba15 100644 --- a/lib/rules/prefer-for-of.js +++ b/lib/rules/prefer-for-of.js @@ -243,7 +243,7 @@ function isIndexVarOnlyUsedToGetArrayElements(context, node) { const arrayText = getArrayTextOfForStatement(sourceCode, node) const indexVar = context.getDeclaredVariables(node.init)[0] - return indexVar.references.every(reference => { + return indexVar.references.every((reference) => { const id = reference.identifier return ( @@ -273,7 +273,8 @@ function isLengthVarOnlyUsedToTest(context, node) { const lengthVar = context.getDeclaredVariables(node.init.declarations[1])[0] return lengthVar.references.every( - reference => reference.init || contains(node.test, reference.identifier) + (reference) => + reference.init || contains(node.test, reference.identifier) ) } @@ -497,8 +498,7 @@ module.exports = { description: "requires for-of statements instead of Array#forEach", category: "Best Practices", recommended: false, - url: - "https://github.com/mysticatea/eslint-plugin/blob/v13.0.0/docs/rules/prefer-for-of.md", + url: "https://github.com/mysticatea/eslint-plugin/blob/v13.0.0/docs/rules/prefer-for-of.md", }, fixable: "code", schema: [], @@ -580,7 +580,7 @@ module.exports = { if ( thisFuncInfo != null && thisFuncInfo.isTarget && - !thisFuncInfo.returnNodes.some(returnNode => + !thisFuncInfo.returnNodes.some((returnNode) => contains(returnNode, node) ) ) { diff --git a/scripts/generate-configs.js b/scripts/generate-configs.js index a0587d1..6884b7c 100644 --- a/scripts/generate-configs.js +++ b/scripts/generate-configs.js @@ -20,9 +20,9 @@ fs.writeFileSync( module.exports = { ${fs .readdirSync(path.resolve(__dirname, "../lib/configs")) - .map(fileName => path.basename(fileName, ".js")) - .filter(id => !id.startsWith("_")) - .map(id => ` "${id}": require("./configs/${id}"),`) + .map((fileName) => path.basename(fileName, ".js")) + .filter((id) => !id.startsWith("_")) + .map((id) => ` "${id}": require("./configs/${id}"),`) .join("\n")} } ` diff --git a/scripts/generate-rules.js b/scripts/generate-rules.js index 141e876..1ff36ce 100644 --- a/scripts/generate-rules.js +++ b/scripts/generate-rules.js @@ -20,14 +20,14 @@ fs.writeFileSync( module.exports = Object.assign( ${fs .readdirSync(path.resolve(__dirname, "../lib/foreign-rules")) - .map(fileName => path.basename(fileName, ".js")) - .map(id => ` require("./foreign-rules/${id}"),`) + .map((fileName) => path.basename(fileName, ".js")) + .map((id) => ` require("./foreign-rules/${id}"),`) .join("\n")} { ${fs .readdirSync(path.resolve(__dirname, "../lib/rules")) - .map(fileName => path.basename(fileName, ".js")) - .map(id => ` "${id}": require("./rules/${id}"),`) + .map((fileName) => path.basename(fileName, ".js")) + .map((id) => ` "${id}": require("./rules/${id}"),`) .join("\n")} } ) diff --git a/tests/lib/configs/_rules.js b/tests/lib/configs/_rules.js index 170f2cb..454caa5 100644 --- a/tests/lib/configs/_rules.js +++ b/tests/lib/configs/_rules.js @@ -13,7 +13,7 @@ const { rules: PluginRulesIndex } = require("@mysticatea/eslint-plugin") const coreRules = new Linter().getRules() const pluginRules = new Map( - Object.keys(PluginRulesIndex).map(key => [ + Object.keys(PluginRulesIndex).map((key) => [ `@mysticatea/${key}`, PluginRulesIndex[key], ]) @@ -39,12 +39,12 @@ module.exports = { * @returns {void} */ validateConfig(config, source) { - Validator.validate(config, source, ruleId => allRules.get(ruleId)) + Validator.validate(config, source, (ruleId) => allRules.get(ruleId)) /* istanbul ignore next */ for (const ruleId of [].concat( Object.keys(config.rules || {}), - ...(config.overrides || []).map(c => Object.keys(c.rules || {})) + ...(config.overrides || []).map((c) => Object.keys(c.rules || {})) )) { const rule = allRules.get(ruleId) if (rule == null) { @@ -74,7 +74,7 @@ module.exports = { */ getCoreRuleNames() { return Array.from(coreRules.keys()).filter( - ruleId => + (ruleId) => !deprecatedRuleNames.has(ruleId) && !removedRuleNames.has(ruleId) ) @@ -87,14 +87,14 @@ module.exports = { */ getPluginRuleNames(pluginName) { return Object.keys(PluginRulesIndex) - .filter(ruleId => + .filter((ruleId) => pluginName === "mysticatea" ? !ruleId.includes("/") : ruleId.startsWith(`${pluginName}/`) ) - .map(ruleId => `@mysticatea/${ruleId}`) + .map((ruleId) => `@mysticatea/${ruleId}`) .filter( - ruleId => + (ruleId) => !deprecatedRuleNames.has(ruleId) && !removedRuleNames.has(ruleId) ) diff --git a/tests/lib/rules/block-scoped-var.js b/tests/lib/rules/block-scoped-var.js index c5385e5..8cb8b03 100644 --- a/tests/lib/rules/block-scoped-var.js +++ b/tests/lib/rules/block-scoped-var.js @@ -14,8 +14,7 @@ new RuleTester().run("block-scoped-var", rule, { "if (true) { var a; a; } else if (true) { var a; a; } else { var a; a; }", "while (true) { var a; a; } do { var a; a; } while (true);", { - code: - "for (var a = 0; a; a) { a; var b; b; } for (var a in []) { a; var b; b; } for (var a of []) { a; var b; b; }", + code: "for (var a = 0; a; a) { a; var b; b; } for (var a in []) { a; var b; b; } for (var a of []) { a; var b; b; }", env: { es6: true }, }, "switch (0) { case 0: var a; a; case 1: a; default: a; } { var a; a; }", @@ -85,8 +84,7 @@ new RuleTester().run("block-scoped-var", rule, { ], }, { - code: - "{ var {x: [a = 0]} = {x: [1]}; a; } { var a; ({x: [a = 0]} = {x: [1]}); }", + code: "{ var {x: [a = 0]} = {x: [1]}; a; } { var a; ({x: [a = 0]} = {x: [1]}); }", env: { es6: true }, errors: [ { diff --git a/tests/lib/rules/prefer-for-of.js b/tests/lib/rules/prefer-for-of.js index 7583264..e7feefd 100644 --- a/tests/lib/rules/prefer-for-of.js +++ b/tests/lib/rules/prefer-for-of.js @@ -37,10 +37,8 @@ tester.run("prefer-for-of", rule, { ], invalid: [ { - code: - "list.forEach(function(value) { return; function foo() { return } });", - output: - "for (let value of list) { continue; function foo() { return } }", + code: "list.forEach(function(value) { return; function foo() { return } });", + output: "for (let value of list) { continue; function foo() { return } }", errors: ["Expected for-of statement."], }, { @@ -62,8 +60,7 @@ tester.run("prefer-for-of", rule, { errors: ["Expected for-of statement."], }, { - code: - "list.forEach(function(value) { return; let obj; this.a }, obj);", + code: "list.forEach(function(value) { return; let obj; this.a }, obj);", output: null, globals: { list: false, obj: false }, errors: ["Expected for-of statement."], @@ -87,8 +84,7 @@ tester.run("prefer-for-of", rule, { errors: ["Expected for-of statement."], }, { - code: - "list.forEach(function(value) { return; foo(a => this[a]) });", + code: "list.forEach(function(value) { return; foo(a => this[a]) });", output: "for (let value of list) { continue; foo(a => list[a]) }", globals: { list: false, obj: false }, errors: ["Expected for-of statement."], @@ -126,8 +122,7 @@ tester.run("prefer-for-of", rule, { errors: ["Expected for-of statement."], }, { - code: - "list.filter(p)\n .map(t)\n .forEach(value => { return });", + code: "list.filter(p)\n .map(t)\n .forEach(value => { return });", output: null, errors: ["Expected for-of statement."], }, @@ -137,38 +132,32 @@ tester.run("prefer-for-of", rule, { errors: ["Expected for-of statement."], }, { - code: - "function wrap() { for (let i = 0; i < list.length; ++i) { return } }", + code: "function wrap() { for (let i = 0; i < list.length; ++i) { return } }", output: null, errors: ["Expected for-of statement."], }, { - code: - "function wrap() { for (let i = 0; i < list.length; ++i) { const value = list[i]; return } }", + code: "function wrap() { for (let i = 0; i < list.length; ++i) { const value = list[i]; return } }", output: "function wrap() { for (let value of list) { return } }", errors: ["Expected for-of statement."], }, { - code: - "function wrap() { for (let i = 0; i < list.length; i++) { const value = list[i]; return } }", + code: "function wrap() { for (let i = 0; i < list.length; i++) { const value = list[i]; return } }", output: "function wrap() { for (let value of list) { return } }", errors: ["Expected for-of statement."], }, { - code: - "function wrap() { for (let i = 0; i < list.length; i += 1) { const value = list[i]; return } }", + code: "function wrap() { for (let i = 0; i < list.length; i += 1) { const value = list[i]; return } }", output: "function wrap() { for (let value of list) { return } }", errors: ["Expected for-of statement."], }, { - code: - "for (let i = 0, end = list.length; i < end;i = 1 + i) { const value = list[i]; }", + code: "for (let i = 0, end = list.length; i < end;i = 1 + i) { const value = list[i]; }", output: "for (let value of list) { }", errors: ["Expected for-of statement."], }, { - code: - "for (let i = 0, length = list.length; i < length; i = i + 1) { const value = list[i]; }", + code: "for (let i = 0, length = list.length; i < length; i = i + 1) { const value = list[i]; }", output: "for (let value of list) { }", errors: ["Expected for-of statement."], }, From 67cf6dbf0051802b6e04686c08746060012b3cbd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C3=ABl=20De=20Boey?= Date: Sat, 18 Dec 2021 04:38:30 +0100 Subject: [PATCH 10/17] chore: run Prettier on codebase --- .eslintrc.yml | 4 +- .github/FUNDING.yml | 2 +- .github/workflows/CI.yml | 84 ++++++++++++------------ .nycrc.yml | 8 +-- .prettierrc.js | 5 ++ README.md | 98 +++++++++++++--------------- docs/rules/arrow-parens.md | 30 +++++---- docs/rules/block-scoped-var.md | 46 +++++++------ docs/rules/no-literal-call.md | 10 +-- docs/rules/no-this-in-static.md | 4 +- docs/rules/no-use-ignored-vars.md | 10 +-- docs/rules/no-useless-rest-spread.md | 9 ++- docs/rules/prefer-for-of.md | 2 +- lib/rules/no-useless-rest-spread.js | 4 +- lib/rules/prefer-for-of.js | 4 +- package.json | 1 + 16 files changed, 162 insertions(+), 159 deletions(-) create mode 100644 .prettierrc.js diff --git a/.eslintrc.yml b/.eslintrc.yml index 6683556..fff3289 100644 --- a/.eslintrc.yml +++ b/.eslintrc.yml @@ -1,4 +1,4 @@ root: true extends: - - plugin:@mysticatea/es2015 - - plugin:@mysticatea/+eslint-plugin + - plugin:@mysticatea/es2015 + - plugin:@mysticatea/+eslint-plugin diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml index ce763b1..95ec794 100644 --- a/.github/FUNDING.yml +++ b/.github/FUNDING.yml @@ -1,2 +1,2 @@ github: -- mysticatea + - mysticatea diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index c0d188f..7b817f4 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -1,47 +1,47 @@ name: CI on: - push: - branches: [master] - pull_request: - branches: [master] - schedule: - - cron: 0 0 * * 0 + push: + branches: [master] + pull_request: + branches: [master] + schedule: + - cron: 0 0 * * 0 jobs: - test: - name: Test - strategy: - matrix: - os: [ubuntu-latest] - eslint: [6] - node: [12.22.0, 12, 14.17.0, 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: 12.22.0 + test: + name: Test + strategy: + matrix: + os: [ubuntu-latest] + eslint: [6] + node: [12.22.0, 12, 14.17.0, 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: 12.22.0 - runs-on: ${{ matrix.os }} - steps: - - name: Checkout - uses: actions/checkout@v3 - - name: Install Node.js ${{ matrix.node }} - 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 - run: npm run -s codecov - env: - CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} + runs-on: ${{ matrix.os }} + steps: + - name: Checkout + uses: actions/checkout@v3 + - name: Install Node.js ${{ matrix.node }} + 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 + run: npm run -s codecov + env: + CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} diff --git a/.nycrc.yml b/.nycrc.yml index 5bf9a3c..95d8164 100644 --- a/.nycrc.yml +++ b/.nycrc.yml @@ -1,7 +1,7 @@ include: -- lib + - lib exclude: -- lib/processors/vue.js + - lib/processors/vue.js reporter: -- text-summary -- lcov + - text-summary + - lcov diff --git a/.prettierrc.js b/.prettierrc.js new file mode 100644 index 0000000..c60295a --- /dev/null +++ b/.prettierrc.js @@ -0,0 +1,5 @@ +module.exports = { + tabWidth: 4, + semi: false, + trailingComma: "es5", +} diff --git a/README.md b/README.md index a9262ad..b20a186 100644 --- a/README.md +++ b/README.md @@ -16,8 +16,8 @@ npm install --save-dev eslint @mysticatea/eslint-plugin ### Requirements -- Node.js `^12.22.0 || ^14.17.0 || >=16.0.0` or newer versions. -- ESLint `^6.6.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 @@ -25,31 +25,31 @@ Write in your ESLint configurations: http://eslint.org/docs/user-guide/configuri ### Configs -- `plugin:@mysticatea/es2020` ... Basic configuration for ES2020. -- `plugin:@mysticatea/es2019` ... Basic configuration for ES2019. -- `plugin:@mysticatea/es2018` ... Basic configuration for ES2018. -- `plugin:@mysticatea/es2017` ... Basic configuration for ES2017. -- `plugin:@mysticatea/es2016` ... Basic configuration for ES2016. -- `plugin:@mysticatea/es2015` ... Basic configuration for ES2015. -- `plugin:@mysticatea/es5` ... Basic configuration for ES5. -- `plugin:@mysticatea/+modules` ... Additional configuration for ES modules. -- `plugin:@mysticatea/+browser` ... Additional configuration for browser environment. -- `plugin:@mysticatea/+node` ... Additional configuration for Node.js environment. -- `plugin:@mysticatea/+eslint-plugin` ... Additional configuration for ESLint plugins. This includes `plugin:mysticatea/+node` setting. +- `plugin:@mysticatea/es2020` ... Basic configuration for ES2020. +- `plugin:@mysticatea/es2019` ... Basic configuration for ES2019. +- `plugin:@mysticatea/es2018` ... Basic configuration for ES2018. +- `plugin:@mysticatea/es2017` ... Basic configuration for ES2017. +- `plugin:@mysticatea/es2016` ... Basic configuration for ES2016. +- `plugin:@mysticatea/es2015` ... Basic configuration for ES2015. +- `plugin:@mysticatea/es5` ... Basic configuration for ES5. +- `plugin:@mysticatea/+modules` ... Additional configuration for ES modules. +- `plugin:@mysticatea/+browser` ... Additional configuration for browser environment. +- `plugin:@mysticatea/+node` ... Additional configuration for Node.js environment. +- `plugin:@mysticatea/+eslint-plugin` ... Additional configuration for ESLint plugins. This includes `plugin:mysticatea/+node` setting. #### Details The main configurations `plugin:@mysticatea/es*` does: -- detect bug-like code by ESLint rules. -- enforce whitespace style by Prettier. -- handle the `.ts` files as TypeScript then check by `typescript-eslint-parser` and `eslint-plugin-typescript`. -- handle the `.vue` files as Vue.js SFC then check by `vue-eslint-parser` and `eslint-plugin-vue`. -- handle the files in `test`/`tests` directory as `mocha`'s test code. -- handle the files in `scripts` directory as Node.js environment. -- handle the `.eslintrc.js` file as a Node.js script. -- handle the `webpack.config.js` file as a Node.js script. -- handle the `rollup.config.js` file as an ES module. +- detect bug-like code by ESLint rules. +- enforce whitespace style by Prettier. +- handle the `.ts` files as TypeScript then check by `typescript-eslint-parser` and `eslint-plugin-typescript`. +- handle the `.vue` files as Vue.js SFC then check by `vue-eslint-parser` and `eslint-plugin-vue`. +- handle the files in `test`/`tests` directory as `mocha`'s test code. +- handle the files in `scripts` directory as Node.js environment. +- handle the `.eslintrc.js` file as a Node.js script. +- handle the `webpack.config.js` file as a Node.js script. +- handle the `rollup.config.js` file as an ES module. You can use combination of a main configuration and some additional configurations. For examples: @@ -58,10 +58,7 @@ For examples: ```json { - "extends": [ - "plugin:@mysticatea/es2015", - "plugin:@mysticatea/+node" - ] + "extends": ["plugin:@mysticatea/es2015", "plugin:@mysticatea/+node"] } ``` @@ -71,10 +68,7 @@ For examples: ```json { - "extends": [ - "plugin:@mysticatea/es2015", - "plugin:@mysticatea/+browser" - ] + "extends": ["plugin:@mysticatea/es2015", "plugin:@mysticatea/+browser"] } ``` @@ -107,26 +101,26 @@ This plugin has some original rules and foreign rules. #### Original rules -- [@mysticatea/arrow-parens](docs/rules/arrow-parens.md) enforces parens of argument lists (excludes too redundant parens) (fixable). -- [@mysticatea/block-scoped-var](docs/rules/block-scoped-var.md) handles variables which are declared by `var` declaration as block-scoped. It disallows redeclarations, uses from outside of the scope, shadowing. -- [@mysticatea/no-instanceof-array](docs/rules/no-instanceof-array.md) disallows 'instanceof' for Array (fixable). -- [@mysticatea/no-instanceof-wrapper](docs/rules/no-instanceof-wrapper.md) disallows 'instanceof' for wrapper objects (fixable). -- [@mysticatea/no-literal-call](docs/rules/no-literal-call.md) disallows a call of a literal. -- [@mysticatea/no-this-in-static](docs/rules/no-this-in-static.md) disallows `this`/`super` in static methods. -- [@mysticatea/no-use-ignored-vars](docs/rules/no-use-ignored-vars.md) disallows a use of ignored variables. -- [@mysticatea/no-useless-rest-spread](docs/rules/no-useless-rest-spread.md) disallows unnecessary rest/spread operators (fixable). -- [@mysticatea/prefer-for-of](docs/rules/prefer-for-of.md) requires `for-of` statements instead of `Array#forEach` or something like (fixable). +- [@mysticatea/arrow-parens](docs/rules/arrow-parens.md) enforces parens of argument lists (excludes too redundant parens) (fixable). +- [@mysticatea/block-scoped-var](docs/rules/block-scoped-var.md) handles variables which are declared by `var` declaration as block-scoped. It disallows redeclarations, uses from outside of the scope, shadowing. +- [@mysticatea/no-instanceof-array](docs/rules/no-instanceof-array.md) disallows 'instanceof' for Array (fixable). +- [@mysticatea/no-instanceof-wrapper](docs/rules/no-instanceof-wrapper.md) disallows 'instanceof' for wrapper objects (fixable). +- [@mysticatea/no-literal-call](docs/rules/no-literal-call.md) disallows a call of a literal. +- [@mysticatea/no-this-in-static](docs/rules/no-this-in-static.md) disallows `this`/`super` in static methods. +- [@mysticatea/no-use-ignored-vars](docs/rules/no-use-ignored-vars.md) disallows a use of ignored variables. +- [@mysticatea/no-useless-rest-spread](docs/rules/no-useless-rest-spread.md) disallows unnecessary rest/spread operators (fixable). +- [@mysticatea/prefer-for-of](docs/rules/prefer-for-of.md) requires `for-of` statements instead of `Array#forEach` or something like (fixable). #### Foreign rules -- All `@mysticatea/eslint-comments/*` rules are imported from [eslint-plugin-eslint-comments](https://www.npmjs.com/package/eslint-plugin-eslint-comments). -- All `@mysticatea/eslint-plugin/*` rules are imported from [eslint-plugin-eslint-plugin](https://www.npmjs.com/package/eslint-plugin-eslint-plugin). -- All `@mysticatea/node/*` rules are imported from [eslint-plugin-node](https://www.npmjs.com/package/eslint-plugin-node). -- All `@mysticatea/ts/*` rules are imported from [eslint-plugin-typescript](https://www.npmjs.com/package/eslint-plugin-typescript). -- All `@mysticatea/vue/*` rules are imported from [eslint-plugin-vue](https://www.npmjs.com/package/eslint-plugin-vue). -- The `@mysticatea/prettier` rule is imported from [eslint-plugin-prettier](https://www.npmjs.com/package/eslint-plugin-prettier). +- All `@mysticatea/eslint-comments/*` rules are imported from [eslint-plugin-eslint-comments](https://www.npmjs.com/package/eslint-plugin-eslint-comments). +- All `@mysticatea/eslint-plugin/*` rules are imported from [eslint-plugin-eslint-plugin](https://www.npmjs.com/package/eslint-plugin-eslint-plugin). +- All `@mysticatea/node/*` rules are imported from [eslint-plugin-node](https://www.npmjs.com/package/eslint-plugin-node). +- All `@mysticatea/ts/*` rules are imported from [eslint-plugin-typescript](https://www.npmjs.com/package/eslint-plugin-typescript). +- All `@mysticatea/vue/*` rules are imported from [eslint-plugin-vue](https://www.npmjs.com/package/eslint-plugin-vue). +- The `@mysticatea/prettier` rule is imported from [eslint-plugin-prettier](https://www.npmjs.com/package/eslint-plugin-prettier). -> **Q:** Why don't you use those plugins directly?
+> **Q:** Why don't you use those plugins directly? > **A:** The combination with shareable configs and plugins has some problems because shareable configs were not designed to be used with plugins. @nzakas illustrated a way to use plugins as shareable configs together with other plugins in the discussion [eslint/eslint#3458](https://github.com/eslint/eslint/issues/3458#issuecomment-257161846). This is the way. ## đŸš„ Semantic Versioning Policy @@ -135,7 +129,7 @@ This plugin follows [semantic versioning](http://semver.org/) and [ESLint's Sema ## 📰 Changelog -- [GitHub Releases](https://github.com/mysticatea/eslint-plugin/releases) +- [GitHub Releases](https://github.com/mysticatea/eslint-plugin/releases) ## ❀ Contributing @@ -145,8 +139,8 @@ Please use GitHub's Issues/PRs. ### Development Tools -- `npm test` runs tests and measures coverage. -- `npm run clean` removes the coverage result of `npm test` command. -- `npm run coverage` shows the coverage result of `npm test` command. -- `npm run update` updates auto-generated files. -- `npm run watch` runs tests and measures coverage when source code are changed. +- `npm test` runs tests and measures coverage. +- `npm run clean` removes the coverage result of `npm test` command. +- `npm run coverage` shows the coverage result of `npm test` command. +- `npm run update` updates auto-generated files. +- `npm run watch` runs tests and measures coverage when source code are changed. diff --git a/docs/rules/arrow-parens.md b/docs/rules/arrow-parens.md index 9054b31..984d08b 100644 --- a/docs/rules/arrow-parens.md +++ b/docs/rules/arrow-parens.md @@ -12,39 +12,45 @@ This rule ignores arrow functions that there is a open paren before itself. ### The following patterns are considered warnings: ```js -const twice = x => 2 * x; +const twice = (x) => 2 * x ``` ```js const obj = { - twich: x => 2 * x -}; + twich: (x) => 2 * x, +} ``` ```js -p.then(x => 2 * x, err => console.error(err)); +p.then( + (x) => 2 * x, + (err) => console.error(err) +) ``` ### The following patterns are not considered warnings: ```js -const twice = (x) => 2 * x; -const twice = (x => 2 * x); +const twice = (x) => 2 * x +const twice = (x) => 2 * x ``` ```js const obj = { - twich: (x) => 2 * x -}; + twich: (x) => 2 * x, +} const obj2 = { - twich: (x => 2 * x) -}; + twich: (x) => 2 * x, +} ``` ```js -xs.map(x => 2 * x); +xs.map((x) => 2 * x) ``` ```js -p.then(x => 2 * x, (err) => console.error(err)); +p.then( + (x) => 2 * x, + (err) => console.error(err) +) ``` diff --git a/docs/rules/block-scoped-var.md b/docs/rules/block-scoped-var.md index e66b9a2..461b4df 100644 --- a/docs/rules/block-scoped-var.md +++ b/docs/rules/block-scoped-var.md @@ -8,54 +8,53 @@ Please turn `no-redeclare` rule off if you use this rule. This rule aims to flag below about variables which are defined with `var` declaration: -- References from outside of the block which declare the variable. -- Re-declarations in a same block. -- Shadowing in a same function scope. +- References from outside of the block which declare the variable. +- Re-declarations in a same block. +- Shadowing in a same function scope. ### The following patterns are considered warnings: ```js { - var a = 0; + var a = 0 } -console.log(a); // not defined. +console.log(a) // not defined. ``` ```js -for (var a = 0;;) { -} -console.log(a); // not defined. +for (var a = 0; ; ) {} +console.log(a) // not defined. ``` ```js -var a = 0; -var a = 0; // already defined. +var a = 0 +var a = 0 // already defined. ``` ```js -for (var a = 0;;) { - var a = 0; // already defined. +for (var a = 0; ; ) { + var a = 0 // already defined. } ``` ```js function foo(a) { - var a = 0; // already defined. + var a = 0 // already defined. } ``` ```js -var a = 0; +var a = 0 { - var a = 0; // already defined in the upper scope. + var a = 0 // already defined in the upper scope. } ``` ```js function foo(a) { - if (Math.random() < 0.5) { - var a = 0; // already defined in the upper scope. - } + if (Math.random() < 0.5) { + var a = 0 // already defined in the upper scope. + } } ``` @@ -63,11 +62,10 @@ function foo(a) { ```js if (Math.random() < 0.5) { - var a = 0; - console.log(a); -} -else { - var a = 1; - console.log(a); + var a = 0 + console.log(a) +} else { + var a = 1 + console.log(a) } ``` diff --git a/docs/rules/no-literal-call.md b/docs/rules/no-literal-call.md index 733ede7..d649ef7 100644 --- a/docs/rules/no-literal-call.md +++ b/docs/rules/no-literal-call.md @@ -1,4 +1,4 @@ -# Disallow a call of a literal (no-literal-call) +# Disallow a call of a literal (no-literal-call) A call of a literal is a valid syntax, but it would cause a runtime error. @@ -9,8 +9,8 @@ Examples of **incorrect** code for this rule: ```js /*eslint no-literal-call: "error"*/ -123(); -"hello"(); +123() +"hello"() ``` Examples of **correct** code for this rule: @@ -18,6 +18,6 @@ Examples of **correct** code for this rule: ```js /*eslint no-literal-call: "error"*/ -foo(); -(function() {})(); +foo() +;(function () {})() ``` diff --git a/docs/rules/no-this-in-static.md b/docs/rules/no-this-in-static.md index 7a7d64b..efb4dc0 100644 --- a/docs/rules/no-this-in-static.md +++ b/docs/rules/no-this-in-static.md @@ -19,13 +19,13 @@ class A { } static bar() { - this.foo() //ERROR: Unexpected 'this'. + this.foo() //ERROR: Unexpected 'this'. } } class B extends A { static foo() { - super.foo() //ERROR: Unexpected 'super'. + super.foo() //ERROR: Unexpected 'super'. } } ``` diff --git a/docs/rules/no-use-ignored-vars.md b/docs/rules/no-use-ignored-vars.md index e63a63c..aea7c08 100644 --- a/docs/rules/no-use-ignored-vars.md +++ b/docs/rules/no-use-ignored-vars.md @@ -13,11 +13,11 @@ Examples of **incorrect** code for this rule: ```js /*eslint no-use-ignored-vars: "error"*/ -let _foo = 0; -doSomething(_foo); +let _foo = 0 +doSomething(_foo) function foo(_a) { - doSomething(_a); + doSomething(_a) } ``` @@ -26,10 +26,10 @@ Examples of **correct** code for this rule: ```js /*eslint no-use-ignored-vars: "error"*/ -let _foo = 0; +let _foo = 0 function foo(_a) { - doSomething(); + doSomething() } ``` diff --git a/docs/rules/no-useless-rest-spread.md b/docs/rules/no-useless-rest-spread.md index ca1e48b..ebcb001 100644 --- a/docs/rules/no-useless-rest-spread.md +++ b/docs/rules/no-useless-rest-spread.md @@ -25,11 +25,10 @@ Examples of **correct** code for this rule: /*eslint no-useless-rest-spread: "error"*/ let list = [a, b, c, d] -let obj = {a, b, c, d} +let obj = { a, b, c, d } foo(a, b, c) -let [a, b, c, d] = list; -let {a, b, c, d} = obj; -function foo(a, b, c, d) { -} +let [a, b, c, d] = list +let { a, b, c, d } = obj +function foo(a, b, c, d) {} ``` diff --git a/docs/rules/prefer-for-of.md b/docs/rules/prefer-for-of.md index 79144dd..64a9780 100644 --- a/docs/rules/prefer-for-of.md +++ b/docs/rules/prefer-for-of.md @@ -10,7 +10,7 @@ It's more readable than `Array#forEach` since it does not require closures. ```js /*eslint prefer-for-of: "error"*/ -list.forEach(value => { +list.forEach((value) => { doSomething(value) }) diff --git a/lib/rules/no-useless-rest-spread.js b/lib/rules/no-useless-rest-spread.js index ee6ba2b..e15d3e4 100644 --- a/lib/rules/no-useless-rest-spread.js +++ b/lib/rules/no-useless-rest-spread.js @@ -131,11 +131,11 @@ module.exports = { nodeType === "RestElement" && argumentType !== parentType const type1 = nodeType === "RestElement" ? "rest" : "spread" const type2 = - /*eslint-disable @mysticatea/prettier */ + /* eslint-disable @mysticatea/prettier */ isRestParameter ? "parameter" : isArray ? "element" : /* otherwise */ "property" - /*eslint-enable @mysticatea/prettier */ + /* eslint-enable @mysticatea/prettier */ context.report({ node, diff --git a/lib/rules/prefer-for-of.js b/lib/rules/prefer-for-of.js index d63ba15..684d911 100644 --- a/lib/rules/prefer-for-of.js +++ b/lib/rules/prefer-for-of.js @@ -115,7 +115,7 @@ function isTraversingArray(node) { let indexDecl = null let lengthDecl = null - /*eslint-disable @mysticatea/prettier */ + /* eslint-disable @mysticatea/prettier */ return ( init != null && init.type === "VariableDeclaration" && @@ -186,7 +186,7 @@ function isTraversingArray(node) { ) ) ) - /*eslint-enable @mysticatea/prettier */ + /* eslint-enable @mysticatea/prettier */ } /** diff --git a/package.json b/package.json index a598887..b84be2b 100644 --- a/package.json +++ b/package.json @@ -39,6 +39,7 @@ "clean": "rimraf .nyc_output coverage", "coverage": "opener coverage/lcov-report/index.html", "codecov": "codecov --disable=gcov -t $CODECOV_TOKEN", + "format": "prettier -w .", "lint": "eslint lib scripts tests", "test": "npm run -s lint && nyc mocha \"tests/lib/**/*.js\" --reporter dot", "update": "node scripts/generate-browser-globals && node scripts/generate-configs && node scripts/generate-rules", From cbb699bd4385a457ed9789fa56bed7f9a0368bac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C3=ABl=20De=20Boey?= Date: Sat, 18 Dec 2021 04:52:31 +0100 Subject: [PATCH 11/17] feat: update `@typescript-eslint/*` + update configs --- lib/configs/_override-ts.js | 27 ++++++++++++++++++++++++++- package.json | 4 ++-- 2 files changed, 28 insertions(+), 3 deletions(-) diff --git a/lib/configs/_override-ts.js b/lib/configs/_override-ts.js index 900e37c..df3ec34 100644 --- a/lib/configs/_override-ts.js +++ b/lib/configs/_override-ts.js @@ -20,9 +20,13 @@ module.exports = { "@mysticatea/ts/array-type": "error", "@mysticatea/ts/await-thenable": "error", "@mysticatea/ts/ban-ts-comment": "error", + "@mysticatea/ts/ban-tslint-comment": "error", "@mysticatea/ts/class-literal-property-style": "error", + "@mysticatea/ts/comma-dangle": "error", "@mysticatea/ts/comma-spacing": "error", + "@mysticatea/ts/consistent-indexed-object-style": "error", "@mysticatea/ts/consistent-type-assertions": "error", + "@mysticatea/ts/consistent-type-imports": "error", "@mysticatea/ts/default-param-last": "error", "@mysticatea/ts/dot-notation": "error", "@mysticatea/ts/explicit-member-accessibility": "error", @@ -34,7 +38,10 @@ module.exports = { "@mysticatea/ts/naming-convention": "error", "@mysticatea/ts/no-array-constructor": "error", "@mysticatea/ts/no-base-to-string": "error", + "@mysticatea/ts/no-confusing-non-null-assertion": "error", + "@mysticatea/ts/no-confusing-void-expression": "error", "@mysticatea/ts/no-dupe-class-members": "error", + "@mysticatea/ts/no-duplicate-imports": "error", "@mysticatea/ts/no-dynamic-delete": "error", "@mysticatea/ts/no-empty-interface": "error", "@mysticatea/ts/no-extra-non-null-assertion": "error", @@ -42,15 +49,24 @@ module.exports = { "@mysticatea/ts/no-extraneous-class": "error", "@mysticatea/ts/no-floating-promises": "error", "@mysticatea/ts/no-for-in-array": "error", + "@mysticatea/ts/no-implicit-any-catch": "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-loss-of-precision": "error", + "@mysticatea/ts/no-loop-func": "error", + "@mysticatea/ts/no-meaningless-void-operator": "error", "@mysticatea/ts/no-misused-new": "error", "@mysticatea/ts/no-misused-promises": "error", + "@mysticatea/ts/no-non-null-asserted-nullish-coalescing": + "error", "@mysticatea/ts/no-non-null-asserted-optional-chain": "error", "@mysticatea/ts/no-parameter-properties": "error", + "@mysticatea/ts/no-redeclare": "error", "@mysticatea/ts/no-require-imports": "error", + "@mysticatea/ts/no-restricted-imports": "error", + "@mysticatea/ts/no-shadow": "error", "@mysticatea/ts/no-this-alias": [ "error", { allowDestructuring: true }, @@ -61,17 +77,23 @@ module.exports = { "@mysticatea/ts/no-unnecessary-qualifier": "error", "@mysticatea/ts/no-unnecessary-type-arguments": "error", "@mysticatea/ts/no-unnecessary-type-assertion": "error", + "@mysticatea/ts/no-unnecessary-type-constraint": "error", + "@mysticatea/ts/no-unsafe-argument": "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/non-nullable-type-assertion-style": "error", + "@mysticatea/ts/object-curly-spacing": "error", + "@mysticatea/ts/padding-line-between-statements": "error", "@mysticatea/ts/prefer-as-const": "error", + "@mysticatea/ts/prefer-enum-initializers": "error", // https://github.com/typescript-eslint/typescript-eslint/issues/454 "@mysticatea/ts/prefer-function-type": "off", "@mysticatea/ts/prefer-includes": "error", + "@mysticatea/ts/prefer-literal-enum-member": "error", "@mysticatea/ts/prefer-namespace-keyword": "error", "@mysticatea/ts/prefer-nullish-coalescing": "error", "@mysticatea/ts/prefer-optional-chain": "error", @@ -80,13 +102,16 @@ module.exports = { "@mysticatea/ts/prefer-readonly": "off", "@mysticatea/ts/prefer-reduce-type-parameter": "off", "@mysticatea/ts/prefer-regexp-exec": "error", + "@mysticatea/ts/prefer-return-this-type": "off", "@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/sort-type-union-intersection-members": "error", "@mysticatea/ts/space-before-function-paren": "error", + "@mysticatea/ts/space-infix-ops": "error", "@mysticatea/ts/switch-exhaustiveness-check": "error", "@mysticatea/ts/triple-slash-reference": "error", // ăȘんかèȘ€æ€œçŸ„ăŒć€šă„... diff --git a/package.json b/package.json index 99120dd..a61cf58 100644 --- a/package.json +++ b/package.json @@ -13,8 +13,8 @@ "eslint": ">=6.6.0" }, "dependencies": { - "@typescript-eslint/eslint-plugin": "^2.34.0", - "@typescript-eslint/parser": "^2.34.0", + "@typescript-eslint/eslint-plugin": "^4.33.0", + "@typescript-eslint/parser": "^4.33.0", "eslint-plugin-eslint-comments": "^3.2.0", "eslint-plugin-eslint-plugin": "^2.3.0", "eslint-plugin-node": "^10.0.0", 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 12/17] 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 13/17] 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" }) }, } }, From 34758dfb55c799f0dd3c81b85146422330fbd821 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C3=ABl=20De=20Boey?= Date: Sat, 18 Dec 2021 05:19:22 +0100 Subject: [PATCH 14/17] feat: update `eslint-plugin-node` + update configs --- lib/configs/+node.js | 11 +++++++++++ package.json | 2 +- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/lib/configs/+node.js b/lib/configs/+node.js index b151b63..19e59d2 100644 --- a/lib/configs/+node.js +++ b/lib/configs/+node.js @@ -46,12 +46,15 @@ module.exports = { require: "readonly", }, rules: { + "@mysticatea/node/callback-return": "error", "@mysticatea/node/exports-style": ["error", "module.exports"], "@mysticatea/node/file-extension-in-import": [ "error", "always", { ".js": "never", ".ts": "never", ".tsx": "never" }, ], + "@mysticatea/node/global-require": "error", + "@mysticatea/node/handle-callback-err": "error", "@mysticatea/node/no-callback-literal": "off", "@mysticatea/node/no-deprecated-api": "error", "@mysticatea/node/no-exports-assign": "error", @@ -59,6 +62,14 @@ module.exports = { "@mysticatea/node/no-extraneous-require": "error", "@mysticatea/node/no-missing-import": "error", "@mysticatea/node/no-missing-require": "error", + "@mysticatea/node/no-mixed-requires": "error", + "@mysticatea/node/no-new-require": "error", + "@mysticatea/node/no-path-concat": "error", + "@mysticatea/node/no-process-env": "error", + "@mysticatea/node/no-process-exit": "error", + "@mysticatea/node/no-restricted-import": "error", + "@mysticatea/node/no-restricted-require": "error", + "@mysticatea/node/no-sync": "error", "@mysticatea/node/no-unpublished-bin": "error", "@mysticatea/node/no-unpublished-import": "error", "@mysticatea/node/no-unpublished-require": "error", diff --git a/package.json b/package.json index 99120dd..2f1fb10 100644 --- a/package.json +++ b/package.json @@ -17,7 +17,7 @@ "@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-node": "^11.1.0", "eslint-plugin-prettier": "^3.4.1", "eslint-plugin-vue": "^6.2.2", "prettier": "^1.19.1", From 74e86c1e04b10442faf6434d23d9a2cfeae183b1 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 15/17] 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") From 17a6cac9910b843f76ecad1952a5455e6d97edbe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C3=ABl=20De=20Boey?= Date: Sat, 18 Dec 2021 05:37:14 +0100 Subject: [PATCH 16/17] feat: update `eslint-plugin-vue` + update configs --- lib/configs/_override-vue.js | 178 +++++++++++++++++++++++++++-------- package.json | 2 +- 2 files changed, 139 insertions(+), 41 deletions(-) diff --git a/lib/configs/_override-vue.js b/lib/configs/_override-vue.js index 005f32e..a91fd80 100644 --- a/lib/configs/_override-vue.js +++ b/lib/configs/_override-vue.js @@ -15,9 +15,14 @@ module.exports = { parser: require.resolve("vue-eslint-parser"), rules: { // Enabled rules + "@mysticatea/vue/array-bracket-newline": "error", "@mysticatea/vue/array-bracket-spacing": ["error", "never"], "@mysticatea/vue/arrow-spacing": "error", + "@mysticatea/vue/attribute-hyphenation": "error", + "@mysticatea/vue/attributes-order": "error", + "@mysticatea/vue/block-lang": "error", "@mysticatea/vue/block-spacing": "error", + "@mysticatea/vue/block-tag-newline": "error", "@mysticatea/vue/brace-style": "error", "@mysticatea/vue/camelcase": "error", "@mysticatea/vue/comma-dangle": [ @@ -30,15 +35,41 @@ module.exports = { functions: "always", }, ], + "@mysticatea/vue/comma-spacing": "error", + "@mysticatea/vue/comma-style": "error", "@mysticatea/vue/comment-directive": "error", + "@mysticatea/vue/component-api-style": "error", "@mysticatea/vue/component-definition-name-casing": "error", + "@mysticatea/vue/component-name-in-template-casing": [ + "error", + "kebab-case", + ], "@mysticatea/vue/component-tags-order": "error", + "@mysticatea/vue/custom-event-name-casing": "error", "@mysticatea/vue/dot-location": "error", + "@mysticatea/vue/dot-notation": "error", "@mysticatea/vue/eqeqeq": [ "error", "always", { null: "ignore" }, ], + "@mysticatea/vue/func-call-spacing": "error", + "@mysticatea/vue/html-button-has-type": "error", + "@mysticatea/vue/html-closing-bracket-newline": [ + "error", + { + singleline: "never", + multiline: "always", + }, + ], + "@mysticatea/vue/html-closing-bracket-spacing": "error", + "@mysticatea/vue/html-comment-content-newline": "error", + "@mysticatea/vue/html-comment-content-spacing": "error", + "@mysticatea/vue/html-comment-indent": "error", + "@mysticatea/vue/html-end-tags": "error", + "@mysticatea/vue/html-indent": ["error", 4], + "@mysticatea/vue/html-quotes": "error", + "@mysticatea/vue/html-self-closing": "error", "@mysticatea/vue/jsx-uses-vars": "error", "@mysticatea/vue/key-spacing": "error", "@mysticatea/vue/keyword-spacing": "error", @@ -54,41 +85,146 @@ module.exports = { }, ], "@mysticatea/vue/max-len": ["error", { tabWidth: 4 }], + "@mysticatea/vue/multiline-html-element-content-newline": + "error", + "@mysticatea/vue/multi-word-component-names": "error", + "@mysticatea/vue/mustache-interpolation-spacing": "error", + "@mysticatea/vue/new-line-between-multi-line-property": "error", + "@mysticatea/vue/next-tick-style": "error", + "@mysticatea/vue/no-arrow-functions-in-watch": "error", "@mysticatea/vue/no-async-in-computed-properties": "error", + "@mysticatea/vue/no-bare-strings-in-template": "error", "@mysticatea/vue/no-boolean-default": "error", + "@mysticatea/vue/no-computed-properties-in-data": "error", + "@mysticatea/vue/no-constant-condition": "error", + "@mysticatea/vue/no-custom-modifiers-on-v-model": "error", + "@mysticatea/vue/no-deprecated-data-object-declaration": + "error", + "@mysticatea/vue/no-deprecated-destroyed-lifecycle": "error", + "@mysticatea/vue/no-deprecated-dollar-listeners-api": "error", + "@mysticatea/vue/no-deprecated-dollar-scopedslots-api": "error", + "@mysticatea/vue/no-deprecated-events-api": "error", + "@mysticatea/vue/no-deprecated-filter": "error", + "@mysticatea/vue/no-deprecated-functional-template": "error", + "@mysticatea/vue/no-deprecated-html-element-is": "error", + "@mysticatea/vue/no-deprecated-inline-template": "error", + "@mysticatea/vue/no-deprecated-props-default-this": "error", + "@mysticatea/vue/no-deprecated-router-link-tag-prop": "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-deprecated-v-bind-sync": "error", + "@mysticatea/vue/no-deprecated-v-is": "error", + "@mysticatea/vue/no-deprecated-v-on-native-modifier": "error", + "@mysticatea/vue/no-deprecated-v-on-number-modifiers": "error", + "@mysticatea/vue/no-deprecated-vue-config-keycodes": "error", "@mysticatea/vue/no-dupe-keys": "error", + "@mysticatea/vue/no-dupe-v-else-if": "error", + "@mysticatea/vue/no-duplicate-attr-inheritance": "error", "@mysticatea/vue/no-duplicate-attributes": "error", + "@mysticatea/vue/no-empty-component-block": "error", "@mysticatea/vue/no-empty-pattern": "error", + "@mysticatea/vue/no-export-in-script-setup": "error", + "@mysticatea/vue/no-extra-parens": "error", + "@mysticatea/vue/no-invalid-model-keys": "error", "@mysticatea/vue/no-irregular-whitespace": "error", + "@mysticatea/vue/no-lifecycle-after-await": "error", + "@mysticatea/vue/no-lone-template": "error", + "@mysticatea/vue/no-multiple-objects-in-class": "error", + "@mysticatea/vue/no-multiple-slot-args": "error", + "@mysticatea/vue/no-multiple-template-root": "error", + "@mysticatea/vue/no-multi-spaces": "error", + "@mysticatea/vue/no-mutating-props": "error", "@mysticatea/vue/no-parsing-error": "error", + "@mysticatea/vue/no-potential-component-option-typo": "error", + "@mysticatea/vue/no-ref-as-operand": "error", "@mysticatea/vue/no-reserved-component-names": "error", "@mysticatea/vue/no-reserved-keys": "error", + "@mysticatea/vue/no-restricted-block": "error", + "@mysticatea/vue/no-restricted-call-after-await": "error", + "@mysticatea/vue/no-restricted-class": "error", + "@mysticatea/vue/no-restricted-component-options": "error", + "@mysticatea/vue/no-restricted-custom-event": "error", + "@mysticatea/vue/no-restricted-props": "error", + "@mysticatea/vue/no-restricted-static-attribute": "error", + "@mysticatea/vue/no-restricted-v-bind": "error", + "@mysticatea/vue/no-setup-props-destructure": "error", "@mysticatea/vue/no-shared-component-data": "error", "@mysticatea/vue/no-side-effects-in-computed-properties": "error", + "@mysticatea/vue/no-spaces-around-equal-signs-in-attribute": + "error", + "@mysticatea/vue/no-sparse-arrays": "error", "@mysticatea/vue/no-static-inline-styles": "error", "@mysticatea/vue/no-template-key": "error", + "@mysticatea/vue/no-template-shadow": "error", + "@mysticatea/vue/no-template-target-blank": "error", "@mysticatea/vue/no-textarea-mustache": "error", + "@mysticatea/vue/no-this-in-before-route-enter": "error", + "@mysticatea/vue/no-undef-properties": "error", + "@mysticatea/vue/no-unregistered-components": "error", "@mysticatea/vue/no-unsupported-features": "error", + "@mysticatea/vue/no-unused-components": "error", + "@mysticatea/vue/no-unused-properties": "error", + "@mysticatea/vue/no-unused-refs": "error", "@mysticatea/vue/no-unused-vars": "error", + "@mysticatea/vue/no-use-computed-property-like-method": "error", + "@mysticatea/vue/no-use-v-if-with-v-for": "error", + "@mysticatea/vue/no-useless-concat": "error", + "@mysticatea/vue/no-useless-mustaches": "error", + "@mysticatea/vue/no-useless-template-attributes": "error", + "@mysticatea/vue/no-useless-v-bind": "error", + "@mysticatea/vue/no-v-for-template-key-on-child": "error", + "@mysticatea/vue/no-v-for-template-key": "error", + "@mysticatea/vue/no-v-html": "error", + "@mysticatea/vue/no-v-model-argument": "error", + "@mysticatea/vue/no-v-text": "error", + "@mysticatea/vue/no-watch-after-await": "error", + "@mysticatea/vue/object-curly-newline": "error", "@mysticatea/vue/object-curly-spacing": ["error", "always"], + "@mysticatea/vue/object-property-newline": "error", + "@mysticatea/vue/one-component-per-file": "error", + "@mysticatea/vue/operator-linebreak": "error", + "@mysticatea/vue/order-in-components": "error", "@mysticatea/vue/padding-line-between-blocks": "error", + "@mysticatea/vue/prefer-template": "error", + "@mysticatea/vue/prop-name-casing": "error", "@mysticatea/vue/require-component-is": "error", + "@mysticatea/vue/require-default-prop": "error", "@mysticatea/vue/require-direct-export": "error", + "@mysticatea/vue/require-emit-validator": "error", + "@mysticatea/vue/require-explicit-emits": "error", + "@mysticatea/vue/require-expose": "error", "@mysticatea/vue/require-name-property": "error", + "@mysticatea/vue/require-prop-type-constructor": "error", + "@mysticatea/vue/require-prop-types": "error", "@mysticatea/vue/require-render-return": "error", + "@mysticatea/vue/require-slots-as-functions": "error", + "@mysticatea/vue/require-toggle-inside-transition": "error", "@mysticatea/vue/require-v-for-key": "error", "@mysticatea/vue/require-valid-default-prop": "error", "@mysticatea/vue/return-in-computed-property": "error", + "@mysticatea/vue/return-in-emits-validator": "error", + "@mysticatea/vue/script-setup-uses-vars": "error", + "@mysticatea/vue/singleline-html-element-content-newline": + "error", "@mysticatea/vue/sort-keys": "error", + "@mysticatea/vue/space-in-parens": "error", "@mysticatea/vue/space-infix-ops": "error", "@mysticatea/vue/space-unary-ops": "error", "@mysticatea/vue/static-class-names-order": "error", + "@mysticatea/vue/template-curly-spacing": "error", + "@mysticatea/vue/this-in-template": "error", + "@mysticatea/vue/use-v-on-exact": "error", + "@mysticatea/vue/v-bind-style": "error", + "@mysticatea/vue/v-for-delimiter-style": "error", + "@mysticatea/vue/v-on-event-hyphenation": "error", "@mysticatea/vue/v-on-function-call": "error", + "@mysticatea/vue/v-on-style": "error", "@mysticatea/vue/v-slot-style": "error", + "@mysticatea/vue/valid-define-emits": "error", + "@mysticatea/vue/valid-define-props": "error", + "@mysticatea/vue/valid-next-tick": "error", "@mysticatea/vue/valid-template-root": "error", "@mysticatea/vue/valid-v-bind-sync": "error", "@mysticatea/vue/valid-v-bind": "error", @@ -98,6 +234,8 @@ module.exports = { "@mysticatea/vue/valid-v-for": "error", "@mysticatea/vue/valid-v-html": "error", "@mysticatea/vue/valid-v-if": "error", + "@mysticatea/vue/valid-v-is": "error", + "@mysticatea/vue/valid-v-memo": "error", "@mysticatea/vue/valid-v-model": "error", "@mysticatea/vue/valid-v-on": "error", "@mysticatea/vue/valid-v-once": "error", @@ -105,46 +243,6 @@ module.exports = { "@mysticatea/vue/valid-v-show": "error", "@mysticatea/vue/valid-v-slot": "error", "@mysticatea/vue/valid-v-text": "error", - "@mysticatea/vue/attribute-hyphenation": "error", - "@mysticatea/vue/html-end-tags": "error", - "@mysticatea/vue/html-indent": ["error", 4], - "@mysticatea/vue/html-self-closing": "error", - "@mysticatea/vue/mustache-interpolation-spacing": "error", - "@mysticatea/vue/name-property-casing": "error", - "@mysticatea/vue/no-multi-spaces": "error", - "@mysticatea/vue/require-default-prop": "error", - "@mysticatea/vue/require-prop-types": "error", - "@mysticatea/vue/v-bind-style": "error", - "@mysticatea/vue/v-on-style": "error", - "@mysticatea/vue/attributes-order": "error", - "@mysticatea/vue/html-quotes": "error", - "@mysticatea/vue/order-in-components": "error", - "@mysticatea/vue/this-in-template": "error", - "@mysticatea/vue/html-closing-bracket-newline": [ - "error", - { - singleline: "never", - multiline: "always", - }, - ], - "@mysticatea/vue/html-closing-bracket-spacing": "error", - "@mysticatea/vue/prop-name-casing": "error", - "@mysticatea/vue/component-name-in-template-casing": [ - "error", - "kebab-case", - ], - "@mysticatea/vue/multiline-html-element-content-newline": - "error", - "@mysticatea/vue/singleline-html-element-content-newline": - "error", - "@mysticatea/vue/no-spaces-around-equal-signs-in-attribute": - "error", - "@mysticatea/vue/no-template-shadow": "error", - "@mysticatea/vue/no-unused-components": "error", - "@mysticatea/vue/no-use-v-if-with-v-for": "error", - "@mysticatea/vue/no-v-html": "error", - "@mysticatea/vue/require-prop-type-constructor": "error", - "@mysticatea/vue/use-v-on-exact": "error", // Disabled rules (prefer prettier) "@mysticatea/vue/no-restricted-syntax": "off", diff --git a/package.json b/package.json index 99120dd..dafd8b2 100644 --- a/package.json +++ b/package.json @@ -19,7 +19,7 @@ "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", + "eslint-plugin-vue": "^7.20.0", "prettier": "^1.19.1", "vue-eslint-parser": "^7.11.0" }, From e5591ea79da044eeb9c275ee59314a6fb21f558b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C3=ABl=20De=20Boey?= Date: Sat, 16 May 2020 18:08:38 +0200 Subject: [PATCH 17/17] feat: support ESLint 7.x --- .github/workflows/CI.yml | 5 ++++- README.md | 2 +- lib/configs/_base.js | 10 ++++++++++ lib/configs/_override-special.js | 2 -- package.json | 5 +++-- tests/lib/configs/_rules.js | 2 +- 6 files changed, 19 insertions(+), 7 deletions(-) diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index 7b817f4..dffef30 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -13,7 +13,7 @@ jobs: strategy: matrix: os: [ubuntu-latest] - eslint: [6] + eslint: [7] node: [12.22.0, 12, 14.17.0, 14, 16, 18] include: # On other platforms @@ -21,6 +21,9 @@ jobs: node: 18 - os: macos-latest node: 18 + # On old ESLint versions + - eslint: 6 + node: 18 # On the minimum supported ESLint/Node.js version - eslint: 6.6.0 node: 12.22.0 diff --git a/README.md b/README.md index b20a186..0ea9975 100644 --- a/README.md +++ b/README.md @@ -17,7 +17,7 @@ npm install --save-dev eslint @mysticatea/eslint-plugin ### Requirements - Node.js `^12.22.0 || ^14.17.0 || >=16.0.0` or newer versions. -- ESLint `^6.6.0` or newer versions. +- ESLint `^6.6.0 || ^7.0.0` or newer versions. ## 📖 Usage diff --git a/lib/configs/_base.js b/lib/configs/_base.js index 7708e61..8f55027 100644 --- a/lib/configs/_base.js +++ b/lib/configs/_base.js @@ -26,6 +26,7 @@ module.exports = { camelcase: "error", "consistent-return": "error", curly: "error", + "default-case-last": "error", "default-case": "error", "default-param-last": "error", "dot-notation": "error", @@ -92,6 +93,7 @@ module.exports = { "no-lone-blocks": "error", "no-lonely-if": "error", "no-loop-func": "error", + "no-loss-of-precision": "error", "no-misleading-character-class": "error", "no-mixed-operators": [ "error", @@ -106,12 +108,14 @@ module.exports = { "no-new-object": "error", "no-new-require": "error", "no-new-wrappers": "error", + "no-nonoctal-decimal-escape": "error", "no-obj-calls": "error", "no-octal": "error", "no-octal-escape": "error", "no-param-reassign": ["error", { props: false }], "no-process-env": "error", "no-process-exit": "error", + "no-promise-executor-return": "error", "no-prototype-builtins": "error", "no-redeclare": ["error", { builtinGlobals: true }], "no-regex-spaces": "error", @@ -141,9 +145,11 @@ module.exports = { "no-unexpected-multiline": "error", "no-unmodified-loop-condition": "error", "no-unneeded-ternary": "error", + "no-unreachable-loop": "error", "no-unreachable": "error", "no-unsafe-finally": "error", "no-unsafe-negation": ["error", { enforceForOrderingRelations: true }], + "no-unsafe-optional-chaining": "error", "no-unused-expressions": "error", "no-unused-labels": "error", "no-unused-vars": [ @@ -157,6 +163,7 @@ module.exports = { }, ], "no-use-before-define": ["error", "nofunc"], + "no-useless-backreference": "error", "no-useless-call": "error", "no-useless-catch": "error", "no-useless-concat": "error", @@ -299,6 +306,7 @@ module.exports = { "guard-for-in": "off", "handle-callback-err": "off", "id-blacklist": "off", + "id-denylist": "off", "id-length": "off", "id-match": "off", "line-comment-position": "off", @@ -332,6 +340,7 @@ module.exports = { "no-path-concat": "off", "no-plusplus": "off", "no-proto": "off", + "no-restricted-exports": "off", "no-restricted-globals": "off", "no-restricted-imports": "off", "no-restricted-modules": "off", @@ -392,6 +401,7 @@ module.exports = { ], }, ], + // "@mysticatea/eslint-comments/require-description": "error", "@mysticatea/eslint-comments/require-description": "off", // prettier diff --git a/lib/configs/_override-special.js b/lib/configs/_override-special.js index 17916c0..e24a2fa 100644 --- a/lib/configs/_override-special.js +++ b/lib/configs/_override-special.js @@ -18,7 +18,6 @@ module.exports = { extends: [require.resolve("./+node.js")], rules: { "no-console": "off", - "no-process-env": "off", }, }, { @@ -33,7 +32,6 @@ module.exports = { ], rules: { "no-console": "off", - "no-process-env": "off", }, }, ], diff --git a/package.json b/package.json index 91089ad..d4d4a40 100644 --- a/package.json +++ b/package.json @@ -10,9 +10,10 @@ "lib" ], "peerDependencies": { - "eslint": ">=6.6.0" + "eslint": "^6.6.0 || ^7.0.0" }, "dependencies": { + "@eslint/eslintrc": "^0.4.3", "@typescript-eslint/eslint-plugin": "^4.33.0", "@typescript-eslint/parser": "^4.33.0", "eslint-plugin-eslint-comments": "^3.2.0", @@ -26,7 +27,7 @@ "devDependencies": { "@mysticatea/eslint-plugin": "file:.", "codecov": "^3.8.3", - "eslint": "^6.8.0", + "eslint": "^7.32.0", "globals": "^13.17.0", "mocha": "^9.2.2", "npm-run-all": "^4.1.5", diff --git a/tests/lib/configs/_rules.js b/tests/lib/configs/_rules.js index cbd9afe..5e3cfec 100644 --- a/tests/lib/configs/_rules.js +++ b/tests/lib/configs/_rules.js @@ -7,7 +7,7 @@ const { Linter } = require("eslint") const { ConfigArrayFactory, -} = require("eslint/lib/cli-engine/config-array-factory") +} = require("@eslint/eslintrc/lib/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")