import reactHooks from 'eslint-plugin-react-hooks'; import tseslint from 'typescript-eslint'; import jsxA11y from 'eslint-plugin-jsx-a11y'; import js from '@eslint/js'; import globals from 'globals'; // V10 选项 B · ESLint 9 flat config (Vite 友好) // Sprint 2 G1 闸门: 0 warning export default tseslint.config( { ignores: ['dist/**', 'node_modules/**', 'playwright-report/**', 'test-results/**', 'coverage/**', 'storybook-static/**', 'src/schemas/api-generated.ts', 'src/types/api-generated.d.ts'] }, { extends: [js.configs.recommended, ...tseslint.configs.recommendedTypeChecked], files: ['**/*.{ts,tsx}'], languageOptions: { ecmaVersion: 2022, globals: { ...globals.browser, ...globals.node }, parserOptions: { project: ['./tsconfig.json'], tsconfigRootDir: import.meta.dirname, }, }, plugins: { 'react-hooks': reactHooks, 'jsx-a11y': jsxA11y, }, rules: { // V10 闸门: 严格 0 any '@typescript-eslint/no-explicit-any': 'error', '@typescript-eslint/no-unused-vars': [ 'error', { argsIgnorePattern: '^_', varsIgnorePattern: '^_' }, ], 'react-hooks/rules-of-hooks': 'error', 'react-hooks/exhaustive-deps': 'warn', 'jsx-a11y/alt-text': 'warn', 'jsx-a11y/anchor-is-valid': 'warn', 'jsx-a11y/click-events-have-key-events': 'warn', 'jsx-a11y/no-static-element-interactions': 'warn', }, }, // 测试文件放宽 { files: ['**/*.{test,spec}.{ts,tsx}', 'src/test/**/*.{ts,tsx}'], rules: { '@typescript-eslint/no-explicit-any': 'warn', '@typescript-eslint/no-non-null-assertion': 'off', }, }, );