|
| 1 | +import js from '@eslint/js'; |
| 2 | +import react from 'eslint-plugin-react'; |
| 3 | +import reactHooks from 'eslint-plugin-react-hooks'; |
| 4 | +import reactRefresh from 'eslint-plugin-react-refresh'; |
| 5 | +import prettierConfig from 'eslint-config-prettier'; |
| 6 | + |
| 7 | +export default [ |
| 8 | + { |
| 9 | + ignores: ['dist', 'node_modules', 'public/mockServiceWorker.js'], |
| 10 | + }, |
| 11 | + // Config files (Node.js environment) |
| 12 | + { |
| 13 | + files: ['*.config.js', '*.config.cjs'], |
| 14 | + languageOptions: { |
| 15 | + ecmaVersion: 'latest', |
| 16 | + sourceType: 'module', |
| 17 | + globals: { |
| 18 | + __dirname: 'readonly', |
| 19 | + __filename: 'readonly', |
| 20 | + require: 'readonly', |
| 21 | + module: 'readonly', |
| 22 | + exports: 'writable', |
| 23 | + process: 'readonly', |
| 24 | + }, |
| 25 | + }, |
| 26 | + rules: { |
| 27 | + ...js.configs.recommended.rules, |
| 28 | + }, |
| 29 | + }, |
| 30 | + // React application files |
| 31 | + { |
| 32 | + files: ['src/**/*.{js,jsx}'], |
| 33 | + languageOptions: { |
| 34 | + ecmaVersion: 'latest', |
| 35 | + sourceType: 'module', |
| 36 | + parserOptions: { |
| 37 | + ecmaFeatures: { |
| 38 | + jsx: true, |
| 39 | + }, |
| 40 | + }, |
| 41 | + globals: { |
| 42 | + window: 'readonly', |
| 43 | + document: 'readonly', |
| 44 | + navigator: 'readonly', |
| 45 | + console: 'readonly', |
| 46 | + setTimeout: 'readonly', |
| 47 | + clearTimeout: 'readonly', |
| 48 | + setInterval: 'readonly', |
| 49 | + clearInterval: 'readonly', |
| 50 | + fetch: 'readonly', |
| 51 | + localStorage: 'readonly', |
| 52 | + sessionStorage: 'readonly', |
| 53 | + FormData: 'readonly', |
| 54 | + URL: 'readonly', |
| 55 | + URLSearchParams: 'readonly', |
| 56 | + alert: 'readonly', |
| 57 | + confirm: 'readonly', |
| 58 | + prompt: 'readonly', |
| 59 | + }, |
| 60 | + }, |
| 61 | + plugins: { |
| 62 | + react, |
| 63 | + 'react-hooks': reactHooks, |
| 64 | + 'react-refresh': reactRefresh, |
| 65 | + }, |
| 66 | + rules: { |
| 67 | + ...js.configs.recommended.rules, |
| 68 | + ...react.configs.recommended.rules, |
| 69 | + ...react.configs['jsx-runtime'].rules, |
| 70 | + ...reactHooks.configs.recommended.rules, |
| 71 | + 'react-refresh/only-export-components': ['warn', { allowConstantExport: true }], |
| 72 | + 'react/prop-types': 'off', |
| 73 | + 'react/no-unescaped-entities': 'off', |
| 74 | + 'no-unused-vars': [ |
| 75 | + 'error', |
| 76 | + { |
| 77 | + varsIgnorePattern: '^React$', |
| 78 | + argsIgnorePattern: '^_', |
| 79 | + }, |
| 80 | + ], |
| 81 | + // Disable formatting rules that conflict with Prettier |
| 82 | + ...prettierConfig.rules, |
| 83 | + }, |
| 84 | + settings: { |
| 85 | + react: { |
| 86 | + version: 'detect', |
| 87 | + }, |
| 88 | + }, |
| 89 | + }, |
| 90 | +]; |
0 commit comments