|
| 1 | +import js from '@eslint/js'; |
| 2 | +import globals from 'globals'; |
| 3 | +import reactPlugin from 'eslint-plugin-react'; |
| 4 | +import reactHooksPlugin from 'eslint-plugin-react-hooks'; |
| 5 | +import importPlugin from 'eslint-plugin-import'; |
| 6 | +import jsxA11yPlugin from 'eslint-plugin-jsx-a11y'; |
| 7 | + |
| 8 | +export default [ |
| 9 | + js.configs.recommended, |
| 10 | + { |
| 11 | + files: ['**/*.{js,jsx}'], |
| 12 | + languageOptions: { |
| 13 | + ecmaVersion: 'latest', |
| 14 | + sourceType: 'module', |
| 15 | + globals: { |
| 16 | + ...globals.browser, |
| 17 | + ...globals.es2021, |
| 18 | + ...globals.node, |
| 19 | + }, |
| 20 | + parserOptions: { |
| 21 | + ecmaFeatures: { |
| 22 | + jsx: true, |
| 23 | + }, |
| 24 | + }, |
| 25 | + }, |
| 26 | + plugins: { |
| 27 | + react: reactPlugin, |
| 28 | + 'react-hooks': reactHooksPlugin, |
| 29 | + import: importPlugin, |
| 30 | + 'jsx-a11y': jsxA11yPlugin, |
| 31 | + }, |
| 32 | + settings: { |
| 33 | + react: { |
| 34 | + version: 'detect', |
| 35 | + }, |
| 36 | + }, |
| 37 | + rules: { |
| 38 | + // React rules |
| 39 | + ...reactPlugin.configs.recommended.rules, |
| 40 | + 'react/react-in-jsx-scope': 'off', // Not needed in React 17+ |
| 41 | + 'react/prop-types': 'off', // Disable prop-types (using TypeScript or just JS) |
| 42 | + 'react/display-name': 'off', |
| 43 | + |
| 44 | + // React Hooks rules |
| 45 | + 'react-hooks/rules-of-hooks': 'error', |
| 46 | + 'react-hooks/exhaustive-deps': 'warn', |
| 47 | + |
| 48 | + // Import rules |
| 49 | + 'import/no-unresolved': 'off', // Handled by bundler |
| 50 | + 'import/order': 'off', |
| 51 | + |
| 52 | + // General rules |
| 53 | + 'no-unused-vars': ['warn', { argsIgnorePattern: '^_', varsIgnorePattern: '^_' }], |
| 54 | + 'no-console': 'off', |
| 55 | + eqeqeq: 'warn', |
| 56 | + 'no-self-assign': 'warn', |
| 57 | + 'array-callback-return': 'warn', |
| 58 | + |
| 59 | + // JSX a11y rules (warnings to avoid breaking existing code) |
| 60 | + 'jsx-a11y/anchor-is-valid': 'warn', |
| 61 | + 'jsx-a11y/click-events-have-key-events': 'off', |
| 62 | + 'jsx-a11y/no-static-element-interactions': 'off', |
| 63 | + }, |
| 64 | + }, |
| 65 | + { |
| 66 | + // Test files configuration |
| 67 | + files: ['**/*.test.{js,jsx}', '**/__tests__/**/*.{js,jsx}'], |
| 68 | + languageOptions: { |
| 69 | + globals: { |
| 70 | + ...globals.jest, |
| 71 | + vi: 'readonly', |
| 72 | + describe: 'readonly', |
| 73 | + it: 'readonly', |
| 74 | + expect: 'readonly', |
| 75 | + beforeEach: 'readonly', |
| 76 | + afterEach: 'readonly', |
| 77 | + beforeAll: 'readonly', |
| 78 | + afterAll: 'readonly', |
| 79 | + }, |
| 80 | + }, |
| 81 | + }, |
| 82 | + { |
| 83 | + // Ignore patterns |
| 84 | + ignores: [ |
| 85 | + 'dist/**', |
| 86 | + 'build/**', |
| 87 | + 'node_modules/**', |
| 88 | + 'coverage/**', |
| 89 | + '*.config.js', |
| 90 | + 'vite.config.js', |
| 91 | + ], |
| 92 | + }, |
| 93 | +]; |
0 commit comments