|
| 1 | +import js from '@eslint/js'; |
| 2 | +import globals from 'globals'; |
| 3 | +import reactHooks from 'eslint-plugin-react-hooks'; |
| 4 | +import reactRefresh from 'eslint-plugin-react-refresh'; |
| 5 | +import tseslint from '@typescript-eslint/eslint-plugin'; |
| 6 | +import tsparser from '@typescript-eslint/parser'; |
| 7 | +import react from 'eslint-plugin-react'; |
| 8 | +import jsxA11y from 'eslint-plugin-jsx-a11y'; |
| 9 | +import importPlugin from 'eslint-plugin-import'; |
| 10 | + |
| 11 | +export default [ |
| 12 | + { |
| 13 | + ignores: [ |
| 14 | + 'dist', |
| 15 | + 'build', |
| 16 | + 'node_modules', |
| 17 | + 'coverage', |
| 18 | + '*.config.js', |
| 19 | + '*.config.ts', |
| 20 | + 'public', |
| 21 | + 'scripts', |
| 22 | + ], |
| 23 | + }, |
| 24 | + { |
| 25 | + files: ['**/*.{ts,tsx}'], |
| 26 | + languageOptions: { |
| 27 | + ecmaVersion: 2020, |
| 28 | + globals: { |
| 29 | + ...globals.browser, |
| 30 | + ...globals.node, |
| 31 | + // Vitest globals |
| 32 | + describe: 'readonly', |
| 33 | + it: 'readonly', |
| 34 | + test: 'readonly', |
| 35 | + expect: 'readonly', |
| 36 | + beforeEach: 'readonly', |
| 37 | + afterEach: 'readonly', |
| 38 | + beforeAll: 'readonly', |
| 39 | + afterAll: 'readonly', |
| 40 | + vi: 'readonly', |
| 41 | + }, |
| 42 | + parser: tsparser, |
| 43 | + parserOptions: { |
| 44 | + ecmaVersion: 'latest', |
| 45 | + ecmaFeatures: { jsx: true }, |
| 46 | + sourceType: 'module', |
| 47 | + }, |
| 48 | + }, |
| 49 | + settings: { |
| 50 | + react: { version: '18.3' }, |
| 51 | + 'import/resolver': { |
| 52 | + typescript: { |
| 53 | + alwaysTryTypes: true, |
| 54 | + project: './tsconfig.json', |
| 55 | + }, |
| 56 | + alias: { |
| 57 | + map: [ |
| 58 | + ['@', './src'], |
| 59 | + ['@components', './src/components'], |
| 60 | + ['@views', './src/views'], |
| 61 | + ['@utils', './src/utils'], |
| 62 | + ['@hooks', './src/hooks'], |
| 63 | + ['@types', './src/types'], |
| 64 | + ['@assets', './src/assets'], |
| 65 | + ], |
| 66 | + extensions: ['.ts', '.tsx', '.js', '.jsx', '.json'], |
| 67 | + }, |
| 68 | + }, |
| 69 | + }, |
| 70 | + plugins: { |
| 71 | + react, |
| 72 | + 'react-hooks': reactHooks, |
| 73 | + 'react-refresh': reactRefresh, |
| 74 | + '@typescript-eslint': tseslint, |
| 75 | + 'jsx-a11y': jsxA11y, |
| 76 | + import: importPlugin, |
| 77 | + }, |
| 78 | + rules: { |
| 79 | + ...js.configs.recommended.rules, |
| 80 | + ...tseslint.configs.recommended.rules, |
| 81 | + ...react.configs.recommended.rules, |
| 82 | + ...react.configs['jsx-runtime'].rules, |
| 83 | + ...reactHooks.configs.recommended.rules, |
| 84 | + |
| 85 | + // TypeScript specific rules |
| 86 | + '@typescript-eslint/no-explicit-any': 'error', |
| 87 | + '@typescript-eslint/explicit-function-return-type': 'off', |
| 88 | + '@typescript-eslint/explicit-module-boundary-types': 'off', |
| 89 | + '@typescript-eslint/no-unused-vars': [ |
| 90 | + 'error', |
| 91 | + { |
| 92 | + argsIgnorePattern: '^_', |
| 93 | + varsIgnorePattern: '^_', |
| 94 | + caughtErrorsIgnorePattern: '^_', |
| 95 | + }, |
| 96 | + ], |
| 97 | + '@typescript-eslint/no-non-null-assertion': 'warn', |
| 98 | + '@typescript-eslint/consistent-type-imports': [ |
| 99 | + 'error', |
| 100 | + { |
| 101 | + prefer: 'type-imports', |
| 102 | + disallowTypeAnnotations: false, |
| 103 | + }, |
| 104 | + ], |
| 105 | + |
| 106 | + // React specific rules |
| 107 | + 'react/react-in-jsx-scope': 'off', |
| 108 | + 'react/prop-types': 'off', |
| 109 | + 'react/jsx-uses-react': 'off', |
| 110 | + 'react-refresh/only-export-components': [ |
| 111 | + 'warn', |
| 112 | + { allowConstantExport: true }, |
| 113 | + ], |
| 114 | + |
| 115 | + // Import rules |
| 116 | + 'import/order': [ |
| 117 | + 'error', |
| 118 | + { |
| 119 | + groups: [ |
| 120 | + 'builtin', |
| 121 | + 'external', |
| 122 | + 'internal', |
| 123 | + ['parent', 'sibling'], |
| 124 | + 'index', |
| 125 | + 'object', |
| 126 | + 'type', |
| 127 | + ], |
| 128 | + 'newlines-between': 'always', |
| 129 | + alphabetize: { |
| 130 | + order: 'asc', |
| 131 | + caseInsensitive: true, |
| 132 | + }, |
| 133 | + }, |
| 134 | + ], |
| 135 | + 'import/no-duplicates': 'error', |
| 136 | + 'import/no-unresolved': 'error', |
| 137 | + 'import/named': 'error', |
| 138 | + 'import/default': 'error', |
| 139 | + |
| 140 | + // General code quality rules |
| 141 | + 'no-console': ['warn', { allow: ['warn', 'error'] }], |
| 142 | + 'no-debugger': 'warn', |
| 143 | + 'prefer-const': 'error', |
| 144 | + 'no-var': 'error', |
| 145 | + 'object-shorthand': 'error', |
| 146 | + 'quote-props': ['error', 'as-needed'], |
| 147 | + eqeqeq: ['error', 'always', { null: 'ignore' }], |
| 148 | + 'no-unused-expressions': 'off', // Disabled for styled-components |
| 149 | + 'no-undef': 'off', // TypeScript handles this better |
| 150 | + |
| 151 | + // Accessibility rules |
| 152 | + 'jsx-a11y/alt-text': 'warn', |
| 153 | + 'jsx-a11y/anchor-is-valid': 'warn', |
| 154 | + 'jsx-a11y/click-events-have-key-events': 'warn', |
| 155 | + 'jsx-a11y/no-static-element-interactions': 'warn', |
| 156 | + }, |
| 157 | + }, |
| 158 | +]; |
0 commit comments