import js from '@eslint/js'; import tseslint from 'typescript-eslint'; import reactPlugin from 'eslint-plugin-react'; import reactHooksPlugin from 'eslint-plugin-react-hooks'; export default [ js.configs.recommended, ...tseslint.configs.recommended, { files: ['**/*.{ts,tsx}'], plugins: { react: reactPlugin, 'react-hooks': reactHooksPlugin, }, languageOptions: { parserOptions: { ecmaFeatures: { jsx: true, }, }, }, rules: { // TypeScript 规则 '@typescript-eslint/no-explicit-any': 'warn', '@typescript-eslint/no-unused-vars': ['error', { argsIgnorePattern: '^_', varsIgnorePattern: '^_' }], '@typescript-eslint/explicit-function-return-type': 'off', '@typescript-eslint/explicit-module-boundary-types': 'off', '@typescript-eslint/no-non-null-assertion': 'warn', // React 规则 'react/react-in-jsx-scope': 'off', 'react/prop-types': 'off', 'react/jsx-uses-react': 'off', 'react/jsx-uses-vars': 'error', // React Hooks 规则 'react-hooks/rules-of-hooks': 'error', 'react-hooks/exhaustive-deps': 'warn', // 通用规则 'no-console': ['warn', { allow: ['warn', 'error'] }], 'prefer-const': 'error', 'no-var': 'error', eqeqeq: ['error', 'always'], }, settings: { react: { version: 'detect' }, }, }, { ignores: [ 'dist/', 'node_modules/', 'coverage/', 'src-tauri/', '*.config.js', '*.config.ts', 'tests/e2e/', ], }, ];