Files
deploy/ui/eslint.config.mjs
Jonathan Winters 852bc7b023 chore(ui): fix Rules-of-React violations for React Compiler readiness
Add eslint-plugin-react-hooks v7 (recommended-latest) to surface
Rules-of-React violations, and fix all error-level findings so the
React Compiler can optimize the full component surface.

The React Compiler healthcheck reports 100% of components compilable;
these fixes clear the 48 ESLint errors that would otherwise cause the
compiler to bail out of (or mis-handle) the affected components:

- refs: stop reading/writing ref.current during render
- set-state-in-effect: convert to derived state or restructure effects
- immutability: clone-before-mutate; stop mutating props/state
- rules-of-hooks: hoist hooks to unconditional top-level calls
- static-components: hoist nested component definitions to module scope

Also renames the misnamed useSystemTheme helper (a plain subscription
util, not a hook) to createSystemThemeListener.

All 263 UI unit tests pass; behavior is preserved.

Signed-off-by: Jonathan Winters <[email protected]>
2026-06-22 14:39:36 -07:00

54 lines
1.8 KiB
JavaScript

import globals from 'globals';
import pluginJs from '@eslint/js';
import tseslint from 'typescript-eslint';
import reactX from 'eslint-plugin-react-x';
import reactHooks from 'eslint-plugin-react-hooks';
import pluginReactConfig from 'eslint-plugin-react/configs/recommended.js';
import eslintPluginPrettierRecommended from 'eslint-plugin-prettier/recommended';
export default [
{languageOptions: {globals: globals.browser}},
pluginJs.configs.recommended,
...tseslint.configs.recommended,
{
rules: {
'@typescript-eslint/no-explicit-any': 'off',
// `ban-types` and `no-var-requires` were renamed/split in typescript-eslint v8.
'@typescript-eslint/no-empty-object-type': 'off',
'@typescript-eslint/no-require-imports': 'off'
}
},
{
...reactX.configs.recommended,
rules: {
// ...reactX.configs.strict.rules,
'react-x/no-class-component': 'error'
}
},
{
settings: {
react: {
version: 'detect'
}
},
...pluginReactConfig,
rules: {
// TODO: Re-enable these rules that were disabled by mistake
// ...pluginReactConfig.rules,
'react/display-name': 'off',
'react/no-string-refs': 'off',
'react/prefer-stateless-function': 'error',
'react/jsx-no-useless-fragment': ['error', {allowExpressions: true}]
}
},
eslintPluginPrettierRecommended,
// React Compiler / Rules-of-React lint rules (eslint-plugin-react-hooks v7).
reactHooks.configs.flat['recommended-latest'],
{
files: ['./src/**/*.{ts,tsx}']
},
{
ignores: ['dist', 'assets', '.yalc', 'node_modules', '**/*.config.js', 'jest.setup.js', '__mocks__', 'coverage', '**/*.test.{ts,tsx}']
}
];