Skip to content

Conversation

@yunaotsk
Copy link

Fixes part of #35499
This PR helps detect when React Compiler is enabled, allowing eslint-plugin-react-hooks to bypass unnecessary useCallback/useMemo warnings.

When React Compiler is enabled, it automatically memoizes components, making manual memoization with useCallback and useMemo unnecessary. However, the ESLint plugin was still warning about functions and objects that "change on every render" and suggesting these manual optimizations.

This PR adds a reactCompiler configuration option that can be set either:

  • In rule options: rules: { 'react-hooks/exhaustive-deps': ['warn', { reactCompiler: true }] }
  • In settings: settings: { reactCompiler: true }

When enabled, the plugin skips warnings about constructions that invalidate on every render, while still checking for other dependency issues like missing dependencies.

How did you test this change?

  • Added test cases for reactCompiler: true via rule options
  • Added test cases for reactCompiler: true via settings
  • Verified that with reactCompiler: true, unnecessary memoization warnings are suppressed
  • Verified that other warnings (e.g., missing dependencies) still work correctly
  • Ran yarn linc
  • Ran yarn prettier

@meta-cla meta-cla bot added the CLA Signed label Jan 21, 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