react-hooks ESLint plugin rules are extremely slow, dominating lint time
- React version:
react@19.2.3
eslint-plugin-react-hooks version: eslint-plugin-react-hooks@7.0.1
eslint version: eslint@9.39.1
Steps To Reproduce
- Install
eslint-plugin-react-hooks (the React Compiler ESLint plugin)
- Enable the recommended plugin rules: e.g.
reactHooksPlugin.configs.flat.recommended, jstsFiles
- Run ESLint with
TIMING=50 on a large codebase (~15k+ files)
- Observe that
react-hooks/static-components takes 42-56% of total lint time
Link to code example
Unfortunately, we cannot share a minimal reproduction as this occurs on a large proprietary codebase. However, the performance data should be reproducible on any sufficiently large React codebase.
The current behavior
When running ESLint with the TIMING flag on our codebase, the react-hooks plugin rules dominate lint time:
Rule | Time (ms) | Relative
:------------------------------------------|-----------:|--------:
react-hooks/static-components | 393394.236 | 56.2%
unused-imports/no-unused-imports | 62579.162 | 8.9%
redos-detector/no-unsafe-regex | 35114.790 | 5.0%
import/named | 24641.617 | 3.5%
react-hooks/rules-of-hooks | 16596.903 | 2.4%
...
Key findings:
react-hooks/static-components takes ~393 seconds (6.5 minutes) — more than 5x longer than the next slowest rule
- The react-hooks plugin nearly doubles total lint time: ~3 minutes without the plugin vs ~6 minutes with it enabled
- With 4x parallelism (
--concurrency=4), total ESLint time goes from ~190 seconds to ~370 seconds when the plugin is enabled
- Even if we disable
react-hooks/static-components, another rule jumps up to take the top spot. It seems to trigger from the plugin itself, not any particular rule.
The expected behavior
The react-hooks rules should have comparable performance to other ESLint rules. A single rule taking 42-56% of total lint time and being 5x slower than any other rule suggests there may be optimization opportunities in the rule implementation.
Impact: This performance issue significantly affects CI pipeline times and local development experience. We're considering running these rules as a separate parallel step or disabling them entirely, which isn't ideal.
react-hooks ESLint plugin rules are extremely slow, dominating lint time
react@19.2.3eslint-plugin-react-hooksversion:eslint-plugin-react-hooks@7.0.1eslintversion:eslint@9.39.1Steps To Reproduce
eslint-plugin-react-hooks(the React Compiler ESLint plugin)reactHooksPlugin.configs.flat.recommended, jstsFilesTIMING=50on a large codebase (~15k+ files)react-hooks/static-componentstakes 42-56% of total lint timeLink to code example
Unfortunately, we cannot share a minimal reproduction as this occurs on a large proprietary codebase. However, the performance data should be reproducible on any sufficiently large React codebase.
The current behavior
When running ESLint with the
TIMINGflag on our codebase, thereact-hooksplugin rules dominate lint time:Key findings:
react-hooks/static-componentstakes ~393 seconds (6.5 minutes) — more than 5x longer than the next slowest rule--concurrency=4), total ESLint time goes from ~190 seconds to ~370 seconds when the plugin is enabledreact-hooks/static-components, another rule jumps up to take the top spot. It seems to trigger from the plugin itself, not any particular rule.The expected behavior
The
react-hooksrules should have comparable performance to other ESLint rules. A single rule taking 42-56% of total lint time and being 5x slower than any other rule suggests there may be optimization opportunities in the rule implementation.Impact: This performance issue significantly affects CI pipeline times and local development experience. We're considering running these rules as a separate parallel step or disabling them entirely, which isn't ideal.