Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ESLint] exhaustive-deps rule to also check useInsertionEffect #31969

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

glyph-cat
Copy link

@glyph-cat glyph-cat commented Jan 3, 2025

Summary

  • Updated the eslint-plugin-react-hooks package so that the exhaustive-deps rule would also check useInsertionEffect.
    Screenshot of ESLint reporting violation of exhaustive deps rule when using use insertion effect
  • This could be achieved by specifying 'useInsertionEffect' as an additional hook in the ESLint config file, but considering that this is a built-in hook, it would make more sense for eslint-plugin-react-hooks to handle this out of the box.
    'react-hooks/exhaustive-deps': ['warn', {
      additionalHooks: 'useInsertionEffect',
    }],
  • Related issue: Bug: exhaustive-deps rule doesn't report for useInsertionEffect #31308

How did you test this change?

  • Tests in ESLintRuleExhaustiveDeps-test.js have been updated to also test this change.
  • The changes made are referenced from existing tests for useLayoutEffect.

Please let me know if any scenario is not covered or if my changes to the test are inappropriate as I might have misunderstood the purpose of the existing tests that I was referencing to.

Copy link

vercel bot commented Jan 3, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
react-compiler-playground ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jan 3, 2025 6:42pm

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.

2 participants