-
-
Notifications
You must be signed in to change notification settings - Fork 339
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
linter: react/rule-of-hooks false positives #3257
Comments
I ran it in our product repo just now and it reported 232 false positives 😬. Will try to come up with a short repro when I have time. All the cases I saw were reporting
The components do not have any loops. Edit: at least one comonent had a loop inside hook body |
|
Thanks for providing these examples, The ones without any loop inside of them are really weird to me. I check back edges for detecting cyclic flows and I already know some issues with the current cfg implementation that I'm going to fix while working on #3238. But this one shouldn't be one of them. The last one is almost clear, I'm checking the child loops, and by mistake, I'm also walking in the None of the others seems to have a back edge at first glance, I have to investigate them. If there is any other weird situation please make sure to dump them here. I can use them as test cases while working on an improved cfg and follow-up PR for this rule. Edit:I'm working on a fix that would resolve most of the issues with loop false positives, It would fix the errors mentioned above. I'll let you know when it is ready so you can rerun it on the project and report any other false positives there might be; Since there are probably some other cases that would confuse the linter. |
It is a temporary fix for false positives like [this](#3257 (comment)). Uses the node's ancestors for now instead of the cfg.
After upgrade to 0.4.1 all false positives are gone except 1 scenario. The rule does not seem to handle high order components correctly:
|
Well, those errors are intentional, But we may want to change it to a warning. I'm not sure how large of an impact this change is going to have, Tell me about your experience; How many false positives are out there in your project? and how many higher-order components do you guys have? do you think a whitelist for those function names can be more sufficient here? Looking forward to your feedback. |
These false positives are not a problem for us at all. All errors come from a single file which was long due for a refactor anyway |
Happy to hear that! |
https://github.com/oxc-project/oxlint-ecosystem-ci/actions/runs/9061291729/job/24892841948?pr=2
I haven't checked the details, but I temporary moved the rule nursery 6edcae8 and is making a new release.
The text was updated successfully, but these errors were encountered: