From 2687ebc1c5acb3b938ea07d48904dfaf9634c5d1 Mon Sep 17 00:00:00 2001 From: Jelle van der Waa Date: Mon, 8 Jul 2024 12:35:48 +0200 Subject: [PATCH] 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. --- crates/oxc_linter/src/rules/react/react_in_jsx_scope.rs | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/crates/oxc_linter/src/rules/react/react_in_jsx_scope.rs b/crates/oxc_linter/src/rules/react/react_in_jsx_scope.rs index 34a7f617de8eb..5ea69cb78f7c2 100644 --- a/crates/oxc_linter/src/rules/react/react_in_jsx_scope.rs +++ b/crates/oxc_linter/src/rules/react/react_in_jsx_scope.rs @@ -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)); } }