From 90ca5065eedec6a2f7b7d560c0c0b8bf877b1c27 Mon Sep 17 00:00:00 2001 From: fawney19 Date: Fri, 12 Dec 2025 20:22:22 +0800 Subject: [PATCH] =?UTF-8?q?refactor(frontend):=20=E4=BC=98=E5=8C=96?= =?UTF-8?q?=E9=85=8D=E7=BD=AE=E5=92=8C=E7=B1=BB=E5=9E=8B=E5=AE=9A=E4=B9=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 更新 ESLint 配置 - 优化 Vue 类型声明文件 --- frontend/eslint.config.js | 41 ++++++++++++++++++++++++++++++++++--- frontend/src/shims-vue.d.ts | 5 +++-- 2 files changed, 41 insertions(+), 5 deletions(-) diff --git a/frontend/eslint.config.js b/frontend/eslint.config.js index 0365492..fdca302 100644 --- a/frontend/eslint.config.js +++ b/frontend/eslint.config.js @@ -116,6 +116,33 @@ export default [ ImageData: 'readonly', Path2D: 'readonly', OffscreenCanvas: 'readonly', + // 更多 DOM 类型 + HTMLButtonElement: 'readonly', + HTMLTextAreaElement: 'readonly', + MediaQueryList: 'readonly', + MediaQueryListEvent: 'readonly', + FocusEvent: 'readonly', + DragEvent: 'readonly', + PointerEvent: 'readonly', + TouchEvent: 'readonly', + WheelEvent: 'readonly', + AnimationEvent: 'readonly', + TransitionEvent: 'readonly', + ClipboardEvent: 'readonly', + InputEvent: 'readonly', + CompositionEvent: 'readonly', + UIEvent: 'readonly', + ProgressEvent: 'readonly', + ErrorEvent: 'readonly', + StorageEvent: 'readonly', + PopStateEvent: 'readonly', + HashChangeEvent: 'readonly', + PageTransitionEvent: 'readonly', + BeforeUnloadEvent: 'readonly', + MessageEvent: 'readonly', + SecurityPolicyViolationEvent: 'readonly', + DeviceMotionEvent: 'readonly', + DeviceOrientationEvent: 'readonly', }, }, }, @@ -134,10 +161,10 @@ export default [ rules: { // Vue 规则 'vue/multi-word-component-names': 'off', - 'vue/no-v-html': 'error', + 'vue/no-v-html': 'warn', // 降级为警告,某些场景需要使用 'vue/component-api-style': ['error', ['script-setup']], 'vue/component-name-in-template-casing': ['error', 'PascalCase'], - 'vue/custom-event-name-casing': ['error', 'camelCase'], + 'vue/custom-event-name-casing': ['warn', 'camelCase'], // 降级为警告,逐步迁移 'vue/define-macros-order': [ 'error', { @@ -145,7 +172,7 @@ export default [ }, ], 'vue/html-comment-content-spacing': ['error', 'always'], - 'vue/no-unused-refs': 'error', + 'vue/no-unused-refs': 'warn', // 降级为警告 'vue/no-useless-v-bind': 'error', 'vue/padding-line-between-blocks': ['error', 'always'], 'vue/prefer-separate-static-class': 'error', @@ -183,4 +210,12 @@ export default [ 'prefer-arrow-callback': 'error', }, }, + + // 允许 main.ts 和 logger.ts 使用 console + { + files: ['**/main.ts', '**/logger.ts'], + rules: { + 'no-console': 'off', + }, + }, ] diff --git a/frontend/src/shims-vue.d.ts b/frontend/src/shims-vue.d.ts index 4ca75b5..b5e5539 100644 --- a/frontend/src/shims-vue.d.ts +++ b/frontend/src/shims-vue.d.ts @@ -1,5 +1,6 @@ declare module '*.vue' { import type { DefineComponent } from 'vue' - const component: DefineComponent<{}, {}, any> + // eslint-disable-next-line @typescript-eslint/no-empty-object-type + const component: DefineComponent<{}, {}, unknown> export default component -} \ No newline at end of file +}