Skip to content

fix(eslint-plugin-react-hooks): stabilize flat config typing and binding#36118

Open
mrsandy1965 wants to merge 2 commits intofacebook:mainfrom
mrsandy1965:fix/eslint-plugin-react-hooks-flat-config-typing
Open

fix(eslint-plugin-react-hooks): stabilize flat config typing and binding#36118
mrsandy1965 wants to merge 2 commits intofacebook:mainfrom
mrsandy1965:fix/eslint-plugin-react-hooks-flat-config-typing

Conversation

@mrsandy1965
Copy link

Problem
eslint-plugin-react-hooks flat config typing used a cast + late mutation pattern ({} as ... + Object.assign), which can weaken strict TypeScript inference and was tied to reports of flat config typing friction.
Also, the flat config getters returned newly allocated objects on every access.

Solution
Refactored flat config construction to be strongly typed and circular-reference-safe without Object.assign, then memoized getter results to avoid repeated allocations.

Changes made

  • Introduced explicit ReactHooksPlugin / flat config types for safer typing.
  • Replaced configs.flat cast-and-assign initialization with typed getters.
  • Corrected flat plugin map typing to use 'react-hooks'.
  • Added local caches for:
    • recommended
    • recommended-latest
      so each object is created once and reused.
  • Added regression test to assert flat presets:
    • bind to the plugin instance
    • reference the expected rules objects.

Testing performed

  • yarn prettier
  • yarn linc
  • cd packages/eslint-plugin-react-hooks && yarn test --silent --no-watchman

Result: all package tests pass (5 suites, 5083 tests).

@meta-cla meta-cla bot added the CLA Signed label Mar 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant