37 lines
1.5 KiB
JavaScript
37 lines
1.5 KiB
JavaScript
|
|
import js from '@eslint/js';
|
||
|
|
import globals from 'globals';
|
||
|
|
import reactHooks from 'eslint-plugin-react-hooks';
|
||
|
|
import reactRefresh from 'eslint-plugin-react-refresh';
|
||
|
|
|
||
|
|
// Flat config scoped to the React client. The point is enforcement of the two
|
||
|
|
// rules that catch real React bugs — rules-of-hooks (conditional hooks) and
|
||
|
|
// exhaustive-deps (stale closures) — which nothing previously checked. Server
|
||
|
|
// code (CommonJS Node) is out of scope here; `npm run check:server` covers it.
|
||
|
|
export default [
|
||
|
|
{ ignores: ['dist/**', 'node_modules/**', 'coverage/**', 'client/**/*.test.*'] },
|
||
|
|
{
|
||
|
|
files: ['client/**/*.{js,jsx}'],
|
||
|
|
languageOptions: {
|
||
|
|
ecmaVersion: 2023,
|
||
|
|
sourceType: 'module',
|
||
|
|
globals: { ...globals.browser },
|
||
|
|
parserOptions: { ecmaFeatures: { jsx: true } },
|
||
|
|
},
|
||
|
|
plugins: {
|
||
|
|
'react-hooks': reactHooks,
|
||
|
|
'react-refresh': reactRefresh,
|
||
|
|
},
|
||
|
|
rules: {
|
||
|
|
...js.configs.recommended.rules,
|
||
|
|
// The two that matter most for correctness:
|
||
|
|
'react-hooks/rules-of-hooks': 'error',
|
||
|
|
'react-hooks/exhaustive-deps': 'warn',
|
||
|
|
// HMR safety (Vite fast-refresh); allow non-component constant exports.
|
||
|
|
'react-refresh/only-export-components': ['warn', { allowConstantExport: true }],
|
||
|
|
// Keep the js-recommended noise as warnings so hook signal isn't drowned out.
|
||
|
|
'no-unused-vars': ['warn', { varsIgnorePattern: '^[A-Z_]', argsIgnorePattern: '^_' }],
|
||
|
|
'no-empty': ['warn', { allowEmptyCatch: true }],
|
||
|
|
},
|
||
|
|
},
|
||
|
|
];
|