-
-
Notifications
You must be signed in to change notification settings - Fork 540
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
📎 Break useExhaustiveDependencies
into two rules
#630
Comments
How would you call the new rule? |
What about |
|
If we implement the suggestion from #2509 , do you think we can close this issue? If I understand correctly, the main reason for splitting is to be able to disable one type of check, while leaving others enabled. But if we can make exceptions per dependency, I think that use case is also covered. |
Closing in favor of #2509. |
I think this suggestion still makes sense even with the special ignore. A way to disable "more dependencies than necessary" rule at least for I am migrating a large codebase right now and having to ignore thousands lines should be unnecessary. |
It’s a fair point, although if it is indeed specific to these hooks (and not others), maybe a more specific configuration option might make sense instead of splitting 🤔 |
I agree that an option for this rule, or maybe in the hook options, would be enough. |
I agree with @flatplate . |
I'd like to highlight that the messaging for the rule doesn't help either. If a useEffect has a dependency on a component prop (an "extra" dependency, that's not directly referenced in the effect code), then the message from Biome incorrectly states that:
which is a misleading, false statement - a component prop is not an "outer scope value" and it sure as hell does "re-render the component". It's not until I started tinkering with the code that I understood that Biome is just unhappy that there is a dependency that's not referenced in the code, but the code is perfectly valid as per official React guidelines. While the "This hook specifies more dependencies than necessary" part makes sense (and could be configurable separately, per this discussion), the second piece of info looks like Biome failed to recognized that the referenced dependency is a reactive value. |
I'd like to implement this (as an option). And I'd also like to make an option to re-enable this behavior: #608 But how should the config object look? Something like this?
But I noticed that the existing config schema is designed to be shared between multiple rules (but it's not actually shared anymore) and adding new keys would change that design. |
Thanks! I’ll assign the issue to you then, @simon-paris. I don’t see an issue with the options as you proposed them. I would suggest it’s better to implement them in separate PRs. |
Description
I was migrating to the newest version of Biome and noticed that it seems to group in two seemingly unrelated rules into one:
× This hook do not specify all of its dependencies.
× This hook specifies more dependencies than necessary.
Inside of
useExhaustiveDependencies
However, there's a problem with doing so this way.
While
does not specify all of its deps
is a rule that's ported over from React's common ESLint rules,specifies more deps than necessary
isn't a rule, as it doesn't break the React Rules of Hooks. Moreover, specifying additional deps is how you're able to get some functionality to work as-expected at times.Because of this, we should:
specifies more deps than necessary
should be broken into a new ruleThe text was updated successfully, but these errors were encountered: