From dc3466d77a0cd7576bf98b2862ad4115e4ebefca Mon Sep 17 00:00:00 2001 From: xingyu Date: Thu, 18 Jun 2026 16:10:01 +0800 Subject: [PATCH] =?UTF-8?q?refactor:=20=E5=B0=86=20unicorn=20/=20TypeScrip?= =?UTF-8?q?t=20=E8=A7=84=E5=88=99=E8=BF=81=E7=A7=BB=E8=87=B3=20oxlint?= =?UTF-8?q?=EF=BC=8C=E5=B9=B6=E5=AE=8C=E5=96=84=20oxfmt=20=E9=85=8D?= =?UTF-8?q?=E7=BD=AE=20(#8067)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * chore: update deps * chore: update archiver v8 * fix: 还原 vue/html-closing-bracket-newline * feat: 增加默认配置和配置注释 * feat: 增加oxlint默认插件配置和注释 * refactor: remove unicorn ESLint configuration and update dependencies - Deleted the unicorn ESLint configuration file from the lint-configs package. - Removed unicorn configuration from the main index file. - Updated oxlint-config to include a comprehensive set of unicorn rules. - Adjusted preferences and vxe-table files to disable specific unicorn rules. - Removed references to eslint-plugin-unicorn from pnpm-lock.yaml and pnpm-workspace.yaml. * refactor: 移除 eslint 的 @typescript-eslint/eslint-plugin 依赖,将 TypeScript 配置迁移到 oxlint * feat: open typeAware * fix: mac 和linux下报错 --- .vscode/settings.json | 2 +- apps/backend-mock/nitro.config.ts | 2 + apps/backend-mock/tsconfig.json | 9 +- .../lint-configs/eslint-config/package.json | 2 - .../eslint-config/src/configs/index.ts | 1 - .../eslint-config/src/configs/typescript.ts | 48 +- .../eslint-config/src/configs/unicorn.ts | 44 - .../eslint-config/src/configs/vue.ts | 8 +- .../lint-configs/eslint-config/src/index.ts | 2 - .../lint-configs/oxfmt-config/src/index.ts | 96 ++ .../oxlint-config/src/configs/overrides.ts | 9 + .../oxlint-config/src/configs/plugins.ts | 19 +- .../oxlint-config/src/configs/typescript.ts | 38 +- .../oxlint-config/src/configs/unicorn.ts | 117 ++ internal/vite-config/src/plugins/archiver.ts | 5 +- package.json | 2 +- packages/@core/base/typings/vue-router.d.ts | 2 +- .../@core/composables/src/use-namespace.ts | 2 +- packages/@core/preferences/src/index.ts | 1 + .../plugins/src/vxe-table/use-viewed-row.ts | 2 +- packages/types/global.d.ts | 2 +- pnpm-lock.yaml | 1339 ++++++++--------- pnpm-workspace.yaml | 80 +- scripts/vsh/src/lint/index.ts | 4 +- 24 files changed, 977 insertions(+), 859 deletions(-) delete mode 100644 internal/lint-configs/eslint-config/src/configs/unicorn.ts diff --git a/.vscode/settings.json b/.vscode/settings.json index ff13cfa9c..993b52039 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -38,7 +38,7 @@ // lint && format "oxc.enable": true, - "oxc.typeAware": false, + "oxc.typeAware": true, "oxc.configPath": "oxlint.config.ts", "oxc.fmt.configPath": "oxfmt.config.ts", "eslint.useFlatConfig": true, diff --git a/apps/backend-mock/nitro.config.ts b/apps/backend-mock/nitro.config.ts index c0fc13e2e..9cc3acdb2 100644 --- a/apps/backend-mock/nitro.config.ts +++ b/apps/backend-mock/nitro.config.ts @@ -1,3 +1,5 @@ +import { defineNitroConfig } from 'nitropack/config'; + import errorHandler from './error'; process.env.COMPATIBILITY_DATE = new Date().toISOString(); diff --git a/apps/backend-mock/tsconfig.json b/apps/backend-mock/tsconfig.json index 43008af1c..25280017a 100644 --- a/apps/backend-mock/tsconfig.json +++ b/apps/backend-mock/tsconfig.json @@ -1,3 +1,10 @@ { - "extends": "./.nitro/types/tsconfig.json" + "$schema": "https://json.schemastore.org/tsconfig", + "extends": "@vben/tsconfig/node.json", + "compilerOptions": { + "paths": { + "~/*": ["./*"] + } + }, + "exclude": ["node_modules", "dist", ".nitro"] } diff --git a/internal/lint-configs/eslint-config/package.json b/internal/lint-configs/eslint-config/package.json index c0ce7615f..c59d4d46e 100644 --- a/internal/lint-configs/eslint-config/package.json +++ b/internal/lint-configs/eslint-config/package.json @@ -28,7 +28,6 @@ }, "dependencies": { "@eslint/js": "catalog:", - "@typescript-eslint/eslint-plugin": "catalog:", "@typescript-eslint/parser": "catalog:", "@vben/oxlint-config": "workspace:*", "eslint": "catalog:", @@ -36,7 +35,6 @@ "eslint-plugin-n": "catalog:", "eslint-plugin-perfectionist": "catalog:", "eslint-plugin-pnpm": "catalog:", - "eslint-plugin-unicorn": "catalog:", "eslint-plugin-unused-imports": "catalog:", "eslint-plugin-vue": "catalog:", "eslint-plugin-yml": "catalog:", diff --git a/internal/lint-configs/eslint-config/src/configs/index.ts b/internal/lint-configs/eslint-config/src/configs/index.ts index 4ed3ea61e..c1c2b4c91 100644 --- a/internal/lint-configs/eslint-config/src/configs/index.ts +++ b/internal/lint-configs/eslint-config/src/configs/index.ts @@ -5,6 +5,5 @@ export * from './node'; export * from './perfectionist'; export * from './pnpm'; export * from './typescript'; -export * from './unicorn'; export * from './vue'; export * from './yaml'; diff --git a/internal/lint-configs/eslint-config/src/configs/typescript.ts b/internal/lint-configs/eslint-config/src/configs/typescript.ts index 5e4157cf2..2f1e21636 100644 --- a/internal/lint-configs/eslint-config/src/configs/typescript.ts +++ b/internal/lint-configs/eslint-config/src/configs/typescript.ts @@ -2,24 +2,17 @@ import type { Linter } from 'eslint'; import { interopDefault } from '../util'; -const rulesCoveredByOxlint = new Set([ - '@typescript-eslint/ban-ts-comment', - '@typescript-eslint/no-non-null-assertion', - '@typescript-eslint/no-unused-expressions', - '@typescript-eslint/no-unused-vars', - '@typescript-eslint/triple-slash-reference', -]); - +/** + * @typescript-eslint 的规则已迁移到 oxlint(typescript 插件)。 + * 这里仅保留 TS 解析器,供其它 eslint 插件(perfectionist、n 等)解析 TS/TSX 文件。 + * 因不再有类型感知规则,已移除 parserOptions.project,eslint 解析更快。 + * + * 注意:移除 @typescript-eslint 插件后,unused-imports/no-unused-vars 会退回核心实现, + * 无法识别 TS 类型签名里的形参(会误报)。故对 TS/TSX/Vue 统一关闭该规则, + * 未使用变量改由 oxlint 的 no-unused-vars(类型感知)负责。 + */ export async function typescript(): Promise { - const [pluginTs, parserTs] = await Promise.all([ - interopDefault(import('@typescript-eslint/eslint-plugin')), - interopDefault(import('@typescript-eslint/parser')), - ] as const); - const strictRules = Object.fromEntries( - Object.entries(pluginTs.configs.strict?.rules ?? {}).filter( - ([ruleName]) => !rulesCoveredByOxlint.has(ruleName), - ), - ); + const parserTs = await interopDefault(import('@typescript-eslint/parser')); return [ { @@ -27,30 +20,23 @@ export async function typescript(): Promise { languageOptions: { parser: parserTs, parserOptions: { - createDefaultProgram: false, ecmaFeatures: { jsx: true, }, ecmaVersion: 'latest', extraFileExtensions: ['.vue'], jsxPragma: 'React', - project: './tsconfig.*.json', sourceType: 'module', }, }, - plugins: { - '@typescript-eslint': pluginTs as any, - }, rules: { - ...pluginTs.configs['eslint-recommended']?.overrides?.[0]?.rules, - ...strictRules, - // '@typescript-eslint/consistent-type-definitions': ['warn', 'interface'], - '@typescript-eslint/consistent-type-definitions': 'off', - '@typescript-eslint/explicit-function-return-type': 'off', - '@typescript-eslint/explicit-module-boundary-types': 'off', - '@typescript-eslint/no-explicit-any': 'off', - '@typescript-eslint/no-namespace': 'off', - '@typescript-eslint/no-use-before-define': 'off', + 'unused-imports/no-unused-vars': 'off', + }, + }, + { + // Vue `