// ESLint Flat Config(P1-5) // 项目此前有 lint 脚本但无任何配置文件(npm run lint 直接报错)。 // 规则取向:未用变量/any 等降为 warn(存量代码渐进清理),错误级规则保持零容忍。 import js from '@eslint/js'; import tseslint from 'typescript-eslint'; export default tseslint.config( { ignores: [ 'node_modules/**', 'dist/**', 'dist-electron/**', 'dist-web/**', 'release/**', 'coverage/**', ], }, js.configs.recommended, ...tseslint.configs.recommended, { files: ['**/*.{ts,tsx}'], languageOptions: { parserOptions: { ecmaVersion: 2022, sourceType: 'module', ecmaFeatures: { jsx: true }, }, }, rules: { // 渐进清理:存量代码存在大量 any 与未用参数,先 warn 后收紧 '@typescript-eslint/no-unused-vars': [ 'warn', { argsIgnorePattern: '^_', varsIgnorePattern: '^_' }, ], '@typescript-eslint/no-explicit-any': 'warn', // switch-case 内声明(项目惯用写法) 'no-case-declarations': 'off', // 测试文件允许 non-null 断言与 any 断言 'no-unsafe-optional-chaining': 'off', }, }, { files: ['**/*.test.ts', '**/*.spec.ts'], rules: { '@typescript-eslint/no-explicit-any': 'off', '@typescript-eslint/no-non-null-assertion': 'off', }, }, { // 安全检测引擎包含大量刻意构造的 Unicode/控制字符正则(防绕过模式), // 这些规则在此文件中是误报 files: ['electron/harness/security/**'], rules: { 'no-misleading-character-class': 'off', 'no-control-regex': 'off', }, }, );