From 81619b6090bc32684a64e3f3adcb835b3b68828b Mon Sep 17 00:00:00 2001 From: dream-weave <62940878+dream-weave@users.noreply.github.com> Date: Fri, 3 Jul 2026 17:12:13 +0800 Subject: [PATCH] fix(lint): align eslint and oxlint rules (#8118) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * docs: 路由文档示例代码同步路由组织新规范 * fix(lint): align eslint and oxlint rules * fix(lint): avoid control character regex --- .../eslint-config/src/configs/javascript.ts | 5 ++++- .../oxlint-config/src/configs/javascript.ts | 10 +++++++++- internal/lint-configs/oxlint-config/src/configs/vue.ts | 1 + internal/node-utils/src/git.ts | 8 +++++++- 4 files changed, 21 insertions(+), 3 deletions(-) diff --git a/internal/lint-configs/eslint-config/src/configs/javascript.ts b/internal/lint-configs/eslint-config/src/configs/javascript.ts index bd9bd852b..0cab71f11 100644 --- a/internal/lint-configs/eslint-config/src/configs/javascript.ts +++ b/internal/lint-configs/eslint-config/src/configs/javascript.ts @@ -16,6 +16,7 @@ const rulesCoveredByOxlint = new Set([ 'no-const-assign', 'no-constant-binary-expression', 'no-constant-condition', + 'no-control-regex', 'no-debugger', 'no-delete-var', 'no-dupe-args', @@ -48,6 +49,8 @@ const rulesCoveredByOxlint = new Set([ 'no-shadow-restricted-names', 'no-sparse-arrays', 'no-this-before-super', + 'no-unassigned-vars', + 'no-unexpected-multiline', 'no-unreachable', 'no-unsafe-finally', 'no-unsafe-negation', @@ -59,6 +62,7 @@ const rulesCoveredByOxlint = new Set([ 'no-useless-catch', 'no-useless-escape', 'no-with', + 'preserve-caught-error', 'require-yield', 'use-isnan', 'valid-typeof', @@ -102,7 +106,6 @@ export async function javascript(): Promise { ...recommendedRules, 'dot-notation': ['error', { allowKeywords: true }], 'keyword-spacing': 'off', - 'no-control-regex': 'error', 'no-empty-function': 'off', 'no-octal': 'error', 'no-octal-escape': 'error', diff --git a/internal/lint-configs/oxlint-config/src/configs/javascript.ts b/internal/lint-configs/oxlint-config/src/configs/javascript.ts index 4352c8017..89784dc36 100644 --- a/internal/lint-configs/oxlint-config/src/configs/javascript.ts +++ b/internal/lint-configs/oxlint-config/src/configs/javascript.ts @@ -41,7 +41,7 @@ const javascript: OxlintConfig = { 'no-caller': 'error', 'no-case-declarations': 'error', 'no-console': ['error', { allow: ['warn', 'error'] }], - 'no-control-regex': 'off', + 'no-control-regex': 'error', 'no-debugger': 'error', 'no-empty': ['error', { allowEmptyCatch: true }], 'no-fallthrough': 'error', @@ -68,6 +68,8 @@ const javascript: OxlintConfig = { ], 'no-template-curly-in-string': 'error', 'no-throw-literal': 'error', + 'no-unassigned-vars': 'error', + 'no-unexpected-multiline': 'error', 'no-unused-expressions': [ 'error', { @@ -108,6 +110,12 @@ const javascript: OxlintConfig = { 'prefer-rest-params': 'error', 'prefer-spread': 'error', 'prefer-template': 'error', + 'preserve-caught-error': [ + 'error', + { + requireCatchParameter: false, + }, + ], 'symbol-description': 'error', 'unicode-bom': ['error', 'never'], 'use-isnan': [ diff --git a/internal/lint-configs/oxlint-config/src/configs/vue.ts b/internal/lint-configs/oxlint-config/src/configs/vue.ts index 172507d69..6e140b85d 100644 --- a/internal/lint-configs/oxlint-config/src/configs/vue.ts +++ b/internal/lint-configs/oxlint-config/src/configs/vue.ts @@ -2,6 +2,7 @@ import type { OxlintConfig } from 'oxlint'; const vue: OxlintConfig = { rules: { + 'vue/no-reserved-component-names': 'off', 'vue/prefer-import-from-vue': 'error', }, }; diff --git a/internal/node-utils/src/git.ts b/internal/node-utils/src/git.ts index 88f159cc5..da6dc74cc 100644 --- a/internal/node-utils/src/git.ts +++ b/internal/node-utils/src/git.ts @@ -20,7 +20,13 @@ async function getStagedFiles(): Promise { '-z', ]); - let changedList = stdout ? stdout.replace(/\0$/, '').split('\0') : []; + const nullSeparator = '\u0000'; + const normalizedStdout = stdout.endsWith(nullSeparator) + ? stdout.slice(0, -1) + : stdout; + let changedList = normalizedStdout + ? normalizedStdout.split(nullSeparator) + : []; changedList = changedList.map((item) => path.resolve(process.cwd(), item)); const changedSet = new Set(changedList); changedSet.delete('');