-
Notifications
You must be signed in to change notification settings - Fork 50k
Feature: Add support to exhaustive-deps rule for any hook ending with Effect
#18580
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
Feature: Add support to exhaustive-deps rule for any hook ending with Effect
#18580
Conversation
exhaustive-deps rule for any hook ending with Effect
|
This pull request is automatically built and testable in CodeSandbox. To see build info of the built libraries, click here or the icon next to each commit SHA. Latest deployment of this branch, based on commit 47994e7:
|
|
Oh my code is so much nicer. Thank you thank you. |
|
Thanks. |
|
This heuristic seems very prone to false positives, we have a bunch of custom "Effect" hooks that don't take dep arguments and now require pragma's to avoid warnings about potential infinite updates |
|
I am using hooks.macro, which adds a few hook utilities that doesn't take a dependency array. This now incorrectly shows up as a warning. |
|
One thing we could do is to only run checks if you have a function followed by an array, in addition to ending with Effect. But I'm leaning towards reverting this altogether. There's indeed been too many false positives being reported. |
…nding with `Effect` (facebook#18580)" This reverts commit 5ac9ca7.
|
I'm going to have to revert this because the heuristic has too many reasonable false positives. |
|
This is removed in |
Summary
Following up on @gaearon 's comment here. My original motivation was to document the
additionalHooksoption in theexhaustive-depslint rule. He suggested an alternate solution by linting any hook ending withEffect. This PR adds support for that.Test Plan
I find that eslint rule tests are pretty thorough so all my testing is just through those test cases. I copied all the tests I could find for the
additionalHooksoption and reworked them to use auseXEffectnaming convention instead of theadditionalHooksoption. I also tweaked some of theadditionalHookstests that were testing foruseCustomEffectand changed it touseCustomHookbecauseuseCustomEffectwould get caught anyway after these changes.