Skip to content

Commit

Permalink
refactor(react): use find_binding helper for finding React binding (#…
Browse files Browse the repository at this point in the history
…4108)

Discovered `find_binding()` when hacking on
#4087 seemed like a nice
refactor.
  • Loading branch information
jelly authored Jul 8, 2024
1 parent ed4c54c commit 2687ebc
Showing 1 changed file with 1 addition and 4 deletions.
5 changes: 1 addition & 4 deletions crates/oxc_linter/src/rules/react/react_in_jsx_scope.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}
}
Expand Down

0 comments on commit 2687ebc

Please sign in to comment.