// ESLint Flat Config(P1-5) // 项目此前有 lint 脚本但无任何配置文件(npm run lint 直接报错)。 // 规则取向:部分规则(no-unused-vars / no-explicit-any)配置为 warn 级别以便渐进收紧, // 但执行标准是零容忍 —— `npm run lint` 必须返回 0 problems(0 error / 0 warning), // 新增代码不允许引入任何 warning(v0.4.0 起确立的工程质量基线)。 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', }, }, );