|
| 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' |
| 6 | + |
| 7 | +export default tseslint.config( |
| 8 | + { |
| 9 | + ignores: [ |
| 10 | + 'dist', |
| 11 | + 'coverage', |
| 12 | + 'docs/.vitepress/cache', |
| 13 | + 'docs/.vitepress/dist', |
| 14 | + 'src-tauri/target', |
| 15 | + ], |
| 16 | + }, |
| 17 | + { |
| 18 | + files: ['src/**/*.{ts,tsx}'], |
| 19 | + extends: [js.configs.recommended, ...tseslint.configs.recommended], |
| 20 | + languageOptions: { |
| 21 | + ecmaVersion: 2020, |
| 22 | + globals: globals.browser, |
| 23 | + }, |
| 24 | + plugins: { |
| 25 | + 'react-hooks': reactHooks, |
| 26 | + 'react-refresh': reactRefresh, |
| 27 | + }, |
| 28 | + rules: { |
| 29 | + // The gate this config exists for: an early return above a hook silently |
| 30 | + // reset ResponsePanel's state (see the comment in ResponsePanel.tsx). |
| 31 | + 'react-hooks/rules-of-hooks': 'error', |
| 32 | + 'react-hooks/exhaustive-deps': 'warn', |
| 33 | + |
| 34 | + 'react-refresh/only-export-components': [ |
| 35 | + 'warn', |
| 36 | + { allowConstantExport: true }, |
| 37 | + ], |
| 38 | + |
| 39 | + // tsc already enforces noUnusedLocals/noUnusedParameters, and it |
| 40 | + // understands the `_`-prefix convention better than the lint rule. |
| 41 | + '@typescript-eslint/no-unused-vars': 'off', |
| 42 | + |
| 43 | + // Pre-existing `any`s in the script runner and persistence layers are |
| 44 | + // deliberate (user scripts, JSON round-trips). Flagged, but not a gate. |
| 45 | + '@typescript-eslint/no-explicit-any': 'warn', |
| 46 | + }, |
| 47 | + }, |
| 48 | + { |
| 49 | + files: ['src/test/**/*.{ts,tsx}', '**/*.test.{ts,tsx}'], |
| 50 | + languageOptions: { |
| 51 | + globals: { ...globals.browser, ...globals.node }, |
| 52 | + }, |
| 53 | + rules: { |
| 54 | + '@typescript-eslint/no-explicit-any': 'off', |
| 55 | + }, |
| 56 | + }, |
| 57 | +) |
0 commit comments