refactor(react): use find_binding helper for finding React binding (#4108)

Discovered `find_binding()` when hacking on
https://github.com/oxc-project/oxc/pull/4087 seemed like a nice
refactor.
This commit is contained in:
Jelle van der Waa 2024-07-08 12:35:48 +02:00 committed by GitHub
parent ed4c54c0de
commit 2687ebc1c5
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -50,10 +50,7 @@ impl Rule for ReactInJsxScope {
return;
}
if !scope
.ancestors(node.scope_id())
.any(|v| scope.get_bindings(v).iter().any(|(k, _)| k.as_str() == react_name))
{
if scope.find_binding(node.scope_id(), react_name).is_none() {
ctx.diagnostic(react_in_jsx_scope_diagnostic(node_span));
}
}