From 65c580b572ec5f9d92d8933a8dc471138327c932 Mon Sep 17 00:00:00 2001 From: Flo Edelmann Date: Fri, 25 Oct 2024 09:56:52 +0200 Subject: [PATCH 1/6] Update development dependencies --- package.json | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/package.json b/package.json index 626268933..28ba4bd78 100644 --- a/package.json +++ b/package.json @@ -67,9 +67,9 @@ }, "devDependencies": { "@ota-meshi/site-kit-eslint-editor-vue": "^0.2.4", - "@stylistic/eslint-plugin": "^2.6.0", + "@stylistic/eslint-plugin": "^2.9.0", "@types/eslint": "^8.56.2", - "@types/eslint-visitor-keys": "^3.3.0", + "@types/eslint-visitor-keys": "^3.3.2", "@types/natural-compare": "^1.4.3", "@types/node": "^14.18.63", "@types/semver": "^7.5.8", @@ -78,24 +78,24 @@ "@typescript-eslint/types": "^7.18.0", "assert": "^2.1.0", "env-cmd": "^10.1.0", - "esbuild": "^0.23.0", + "esbuild": "^0.24.0", "eslint": "^8.57.0", "eslint-config-prettier": "^9.1.0", - "eslint-plugin-eslint-plugin": "~6.2.0", - "eslint-plugin-import": "^2.29.1", + "eslint-plugin-eslint-plugin": "~6.3.1", + "eslint-plugin-import": "^2.31.0", "eslint-plugin-jsonc": "^2.16.0", "eslint-plugin-node-dependencies": "^0.12.0", "eslint-plugin-prettier": "^5.2.1", - "eslint-plugin-unicorn": "^55.0.0", + "eslint-plugin-unicorn": "^56.0.0", "eslint-plugin-vue": "file:.", "espree": "^9.6.1", "events": "^3.3.0", - "markdownlint-cli": "^0.41.0", - "mocha": "^10.7.0", - "nyc": "^17.0.0", + "markdownlint-cli": "^0.42.0", + "mocha": "^10.7.3", + "nyc": "^17.1.0", "pathe": "^1.1.2", "prettier": "^3.3.3", - "typescript": "^5.5.4", - "vitepress": "^1.3.1" + "typescript": "^5.6.3", + "vitepress": "^1.4.1" } } From 09b0d6a0b7ed99efeea1a6220e297a23ea5acb11 Mon Sep 17 00:00:00 2001 From: Flo Edelmann Date: Fri, 25 Oct 2024 09:57:22 +0200 Subject: [PATCH 2/6] Fix `unicorn/consistent-existence-index-check` lint errors --- lib/rules/define-macros-order.js | 2 +- lib/rules/no-unused-refs.js | 2 +- lib/utils/indent-common.js | 6 +++--- lib/utils/indent-ts.js | 2 +- lib/utils/property-references.js | 2 +- lib/utils/selector.js | 2 +- 6 files changed, 8 insertions(+), 8 deletions(-) diff --git a/lib/rules/define-macros-order.js b/lib/rules/define-macros-order.js index 920b5c294..55e6140cd 100644 --- a/lib/rules/define-macros-order.js +++ b/lib/rules/define-macros-order.js @@ -193,7 +193,7 @@ function create(context) { const targetStatementIndex = moveTargetNodes.indexOf(targetStatement) - if (targetStatementIndex >= 0) { + if (targetStatementIndex !== -1) { moveTargetNodes = moveTargetNodes.slice(0, targetStatementIndex) } reportNotOnTop(should.name, moveTargetNodes, targetStatement) diff --git a/lib/rules/no-unused-refs.js b/lib/rules/no-unused-refs.js index 79d82a39d..4896ce25a 100644 --- a/lib/rules/no-unused-refs.js +++ b/lib/rules/no-unused-refs.js @@ -128,7 +128,7 @@ module.exports = { } case 'CallExpression': { const argIndex = parent.arguments.indexOf(node) - if (argIndex > -1) { + if (argIndex !== -1) { // `foo($refs)` hasUnknown = true } diff --git a/lib/utils/indent-common.js b/lib/utils/indent-common.js index bacf43e15..e514e283c 100644 --- a/lib/utils/indent-common.js +++ b/lib/utils/indent-common.js @@ -1531,7 +1531,7 @@ module.exports.defineVisitor = function create( const tokens = tokenStore.getTokensBetween(importToken, node.source) const fromIndex = tokens.map((t) => t.value).lastIndexOf('from') const { fromToken, beforeTokens, afterTokens } = - fromIndex >= 0 + fromIndex !== -1 ? { fromToken: tokens[fromIndex], beforeTokens: tokens.slice(0, fromIndex), @@ -1556,7 +1556,7 @@ module.exports.defineVisitor = function create( removeTokens.shift() for (const token of removeTokens) { const i = beforeTokens.indexOf(token) - if (i >= 0) { + if (i !== -1) { beforeTokens.splice(i, 1) } } @@ -1576,7 +1576,7 @@ module.exports.defineVisitor = function create( rightBrace ]) { const i = beforeTokens.indexOf(token) - if (i >= 0) { + if (i !== -1) { beforeTokens.splice(i, 1) } } diff --git a/lib/utils/indent-ts.js b/lib/utils/indent-ts.js index f021e8a10..314858c9a 100644 --- a/lib/utils/indent-ts.js +++ b/lib/utils/indent-ts.js @@ -663,7 +663,7 @@ function defineVisitor({ const [, ...removeTokens] = tokenStore.getTokens(child) for (const token of removeTokens) { const i = afterTokens.indexOf(token) - if (i >= 0) { + if (i !== -1) { afterTokens.splice(i, 1) } } diff --git a/lib/utils/property-references.js b/lib/utils/property-references.js index 57fe59975..99c73293b 100644 --- a/lib/utils/property-references.js +++ b/lib/utils/property-references.js @@ -343,7 +343,7 @@ function definePropertyReferenceExtractor( case 'CallExpression': { const argIndex = parent.arguments.indexOf(node) // `foo(arg)` - return !withInTemplate && argIndex > -1 + return !withInTemplate && argIndex !== -1 ? extractFromCall(parent, argIndex) : NEVER } diff --git a/lib/utils/selector.js b/lib/utils/selector.js index 7b1f15c3f..b5aa1adfc 100644 --- a/lib/utils/selector.js +++ b/lib/utils/selector.js @@ -543,7 +543,7 @@ function parseNth(pseudoNode) { .toLowerCase() const openParenIndex = argumentsText.indexOf('(') const closeParenIndex = argumentsText.lastIndexOf(')') - if (openParenIndex < 0 || closeParenIndex < 0) { + if (openParenIndex === -1 || closeParenIndex === -1) { throw new SelectorError( `Cannot parse An+B micro syntax (:nth-xxx() argument): ${argumentsText}.` ) From 22e5fcd86f0ffe358e6920fb2f289e4753f8ae52 Mon Sep 17 00:00:00 2001 From: Flo Edelmann Date: Fri, 25 Oct 2024 09:58:29 +0200 Subject: [PATCH 3/6] Fix `unicorn/no-negated-condition` lint error --- lib/utils/indent-common.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/utils/indent-common.js b/lib/utils/indent-common.js index e514e283c..d2879b120 100644 --- a/lib/utils/indent-common.js +++ b/lib/utils/indent-common.js @@ -1531,8 +1531,13 @@ module.exports.defineVisitor = function create( const tokens = tokenStore.getTokensBetween(importToken, node.source) const fromIndex = tokens.map((t) => t.value).lastIndexOf('from') const { fromToken, beforeTokens, afterTokens } = - fromIndex !== -1 + fromIndex === -1 ? { + fromToken: null, + beforeTokens: [...tokens, tokenStore.getFirstToken(node.source)], + afterTokens: [] + } + : { fromToken: tokens[fromIndex], beforeTokens: tokens.slice(0, fromIndex), afterTokens: [ @@ -1540,11 +1545,6 @@ module.exports.defineVisitor = function create( tokenStore.getFirstToken(node.source) ] } - : { - fromToken: null, - beforeTokens: [...tokens, tokenStore.getFirstToken(node.source)], - afterTokens: [] - } /** @type {ImportSpecifier[]} */ const namedSpecifiers = [] From 8ef4cfe915d0d1801ee2c43adb83494604ca224e Mon Sep 17 00:00:00 2001 From: Flo Edelmann Date: Fri, 25 Oct 2024 10:00:00 +0200 Subject: [PATCH 4/6] Disable `unicorn/prefer-global-this` rule --- eslint.config.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/eslint.config.js b/eslint.config.js index 5ddca6175..5e25e1708 100644 --- a/eslint.config.js +++ b/eslint.config.js @@ -188,13 +188,14 @@ module.exports = [ 'unicorn/no-null': 'off', 'unicorn/no-array-callback-reference': 'off', // doesn't work well with TypeScript's custom type guards 'unicorn/no-useless-undefined': 'off', - 'unicorn/prefer-optional-catch-binding': 'off', // not supported by current ESLint parser version + 'unicorn/prefer-global-this': 'off', 'unicorn/prefer-module': 'off', - 'unicorn/prevent-abbreviations': 'off', + 'unicorn/prefer-optional-catch-binding': 'off', // not supported by current ESLint parser version 'unicorn/prefer-at': 'off', // turn off to prevent make breaking changes (ref: #2146) 'unicorn/prefer-node-protocol': 'off', // turn off to prevent make breaking changes (ref: #2146) 'unicorn/prefer-string-replace-all': 'off', // turn off to prevent make breaking changes (ref: #2146) 'unicorn/prefer-top-level-await': 'off', // turn off to prevent make breaking changes (ref: #2146) + 'unicorn/prevent-abbreviations': 'off', 'internal/require-eslint-community': ['error'] } From 8cce70d74fec81af4e7d6c321489020603a7ef8c Mon Sep 17 00:00:00 2001 From: Flo Edelmann Date: Fri, 25 Oct 2024 10:38:44 +0200 Subject: [PATCH 5/6] Disable `eslint-plugin/require-meta-schema-description` rule --- eslint.config.js | 1 + 1 file changed, 1 insertion(+) diff --git a/eslint.config.js b/eslint.config.js index 5e25e1708..7eaa682da 100644 --- a/eslint.config.js +++ b/eslint.config.js @@ -148,6 +148,7 @@ module.exports = [ 'error', { catchNoFixerButFixableProperty: true } ], + 'eslint-plugin/require-meta-schema-description': 'off', 'eslint-plugin/report-message-format': ['error', "^[A-Z`'{].*\\.$"], 'no-debugger': 'error', From 74cf43132ac18b2f6f68d0b9e990127e56b24dd6 Mon Sep 17 00:00:00 2001 From: Flo Edelmann Date: Fri, 25 Oct 2024 10:43:16 +0200 Subject: [PATCH 6/6] Disable rules in all files --- eslint.config.js | 35 +++++++++++++++++++++-------------- 1 file changed, 21 insertions(+), 14 deletions(-) diff --git a/eslint.config.js b/eslint.config.js index 7eaa682da..ea76a9d73 100644 --- a/eslint.config.js +++ b/eslint.config.js @@ -42,6 +42,27 @@ module.exports = [ } }, + // turn off some rules from shared configs in all files + { + rules: { + 'eslint-plugin/require-meta-docs-recommended': 'off', // use `categories` instead + 'eslint-plugin/require-meta-schema-description': 'off', + + 'unicorn/filename-case': 'off', + 'unicorn/no-null': 'off', + 'unicorn/no-array-callback-reference': 'off', // doesn't work well with TypeScript's custom type guards + 'unicorn/no-useless-undefined': 'off', + 'unicorn/prefer-global-this': 'off', + 'unicorn/prefer-module': 'off', + 'unicorn/prefer-optional-catch-binding': 'off', // not supported by current ESLint parser version + 'unicorn/prefer-at': 'off', // turn off to prevent make breaking changes (ref: #2146) + 'unicorn/prefer-node-protocol': 'off', // turn off to prevent make breaking changes (ref: #2146) + 'unicorn/prefer-string-replace-all': 'off', // turn off to prevent make breaking changes (ref: #2146) + 'unicorn/prefer-top-level-await': 'off', // turn off to prevent make breaking changes (ref: #2146) + 'unicorn/prevent-abbreviations': 'off' + } + }, + { files: ['**/*.js'], languageOptions: { @@ -143,12 +164,10 @@ module.exports = [ 'error', { pattern: '^(enforce|require|disallow).*[^.]$' } ], - 'eslint-plugin/require-meta-docs-recommended': 'off', // use `categories` instead 'eslint-plugin/require-meta-fixable': [ 'error', { catchNoFixerButFixableProperty: true } ], - 'eslint-plugin/require-meta-schema-description': 'off', 'eslint-plugin/report-message-format': ['error', "^[A-Z`'{].*\\.$"], 'no-debugger': 'error', @@ -185,18 +204,6 @@ module.exports = [ 'error', { checkArrowFunctions: false } ], - 'unicorn/filename-case': 'off', - 'unicorn/no-null': 'off', - 'unicorn/no-array-callback-reference': 'off', // doesn't work well with TypeScript's custom type guards - 'unicorn/no-useless-undefined': 'off', - 'unicorn/prefer-global-this': 'off', - 'unicorn/prefer-module': 'off', - 'unicorn/prefer-optional-catch-binding': 'off', // not supported by current ESLint parser version - 'unicorn/prefer-at': 'off', // turn off to prevent make breaking changes (ref: #2146) - 'unicorn/prefer-node-protocol': 'off', // turn off to prevent make breaking changes (ref: #2146) - 'unicorn/prefer-string-replace-all': 'off', // turn off to prevent make breaking changes (ref: #2146) - 'unicorn/prefer-top-level-await': 'off', // turn off to prevent make breaking changes (ref: #2146) - 'unicorn/prevent-abbreviations': 'off', 'internal/require-eslint-community': ['error'] }