-
-
Notifications
You must be signed in to change notification settings - Fork 482
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
WIP: react-hooks/exhaustive-deps #2637
Conversation
CodSpeed Performance ReportMerging #2637 will not alter performanceComparing Summary
|
@Boshen pushed my latest code. Currently stuck by 2 things:
|
I think I need a completely different approach here. Instead I should iterate over all identifier references and traverse the tree upwards to detect whether I'm in a hook or not. This should remove most of traversal boilerplate I wrote |
This rule is pretty complicated, let's see whether @rzvxa can help. Feel free to ask questions. |
Hey mate, First off thanks for this impressive work. I was reading through the code when I got an idea that might make it easier to implement, Have you tried to create a custom visitor instead of using the If you add something like this: #[derive(Default)]
struct DependencyCollector<'a> {
deps: DependencyList<'a>,
}
impl<'a> Visit<'a> for DependencyCollector<'a> {
fn visit_identifier_reference(&mut self, ident: &IdentifierReference<'a>) {
self.deps.insert(/* dependency */);
}
/* .... */
} and use it like this: DependencyCollector::default().visit_statements(&body_expr.statements); instead of calling the I think it can result in what you want from visiting every identifier, I'm not sure which one is more performant though, Since one skips redundant checks but requires additional visits and the other one has a lot of redundant checks and no additional visit. |
Given the scope_id of the But we have to check Maybe it can be easier if you go for checking the |
How would this approach be different from: ctx.semantic().nodes().iter().for_each(|node| {
let AstKind::IdentifierReference(iref) = node.kind() else { return };
// do stuff
}) Will the visitor visit nodes that the iter above would not? |
I know there are some types missing from If there is nothing important missing in the Just to point out, We recently found out some types are missing a visit event in our Visit trait, So you can see even core stuff can be wrong when written by humans(since the visitor pattern is tedious and has a lot of boilerplate code). But feel free to use either one of these approaches since they should perform the same. |
Hey guys, if anyone else wants to continue working on this please feel free. I thought I would be able to give it more time, but unfortunately I can't. My second child will be born soon so my attention it switched to other pressing matters 😄 |
WOW, Congrats! I'll pick it up in the future, And thanks for all the work you've done on this rule, I'll make sure you get credited as the co-author. I'll announce when I start working on this issue so to anyone who wants to work on this, Until then feel free to propose a PR either based on this or written from scratch. |
@rzvxa I'm not clear how far off completion this is. If it's require a lot of work to finish off, and no obvious prospect of that happening in near future, shall we close it? |
I'm not sure about the correctness of it - as I haven't really reviewed it in depth - but it contains a tremendous amount of work, And all the tests(I assume). It wouldn't hurt to keep it open, Or merge it without adding it to the rules(we already have some empty rules that have been merged after getting blocked, Some of the rules depending on control flow were amount these which since then I've implemented some of them). Either way we should make sure to credit the original author. |
Don't worry about credit guys, do what suits you best |
OK cool. I wasn't aware what a large feature this was. As you say, let's keep it open. I was only trying to do some "tidying up". |
The rule react-hooks/exhaustive-deps is the last missing piece for us to switch over to oxlint exclusively. Much needed! By the way, great work @alisnic and congrats with your second child! |
going to take a look at this |
Continue in #7151 |
I gotta be honest with you - I don't know Rust much and this may be too much for me. But I decided at least I can move things forwarding by creating the scaffolding and porting the tests
Related to #2174