-
Notifications
You must be signed in to change notification settings - Fork 50.2k
Description
react-hooks ESLint plugin rules are extremely slow, dominating lint time
- React version:
react@19.2.3 eslint-plugin-react-hooksversion:eslint-plugin-react-hooks@7.0.1eslintversion: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=50on a large codebase (~15k+ files) - Observe that
react-hooks/static-componentstakes 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-componentstakes ~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.