Skip to content

Perf: react-hooks ESLint plugin (eslint-plugin-react-hooks) rules are extremely slow, dominating lint time #35395

@jordan-cutler

Description

@jordan-cutler

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

  1. Install eslint-plugin-react-hooks (the React Compiler ESLint plugin)
  2. Enable the recommended plugin rules: e.g. reactHooksPlugin.configs.flat.recommended, jstsFiles
  3. Run ESLint with TIMING=50 on a large codebase (~15k+ files)
  4. 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.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions