From 40f047fc3d7ac2263a472d3d3821cf9f7b7facb1 Mon Sep 17 00:00:00 2001 From: camc314 <18101008+camc314@users.noreply.github.com> Date: Tue, 17 Feb 2026 17:19:23 +0000 Subject: [PATCH] refactor(linter/jsx-key): use `IdentifierReference::reference_id` over cell access (#19494) --- crates/oxc_linter/src/rules/react/jsx_key.rs | 26 +++++++++----------- 1 file changed, 12 insertions(+), 14 deletions(-) diff --git a/crates/oxc_linter/src/rules/react/jsx_key.rs b/crates/oxc_linter/src/rules/react/jsx_key.rs index fbb59daa01dbd..fe2121ea7f432 100644 --- a/crates/oxc_linter/src/rules/react/jsx_key.rs +++ b/crates/oxc_linter/src/rules/react/jsx_key.rs @@ -188,20 +188,18 @@ fn is_children_from_react<'a>(ident: &IdentifierReference<'a>, ctx: &LintContext // e.g., const { Children } = React; or const { Children } = Act; if name == CHILDREN { // Get the symbol ID from the reference - if let Some(reference_id) = ident.reference_id.get() { - let reference = ctx.scoping().get_reference(reference_id); - if let Some(symbol_id) = reference.symbol_id() { - // Get the declaration node - let decl_id = ctx.scoping().symbol_declaration(symbol_id); - let decl_node = ctx.nodes().get_node(decl_id); - - // Check if this is a VariableDeclarator with ObjectPattern - if let AstKind::VariableDeclarator(var_decl) = decl_node.kind() { - // Check if init is an identifier imported from React - if let Some(Expression::Identifier(init_ident)) = var_decl.init.as_ref() { - // Check if the init identifier is imported from 'react' module - return import_matcher(ctx, init_ident.name.as_str(), REACT_MODULE); - } + let reference = ctx.scoping().get_reference(ident.reference_id()); + if let Some(symbol_id) = reference.symbol_id() { + // Get the declaration node + let decl_id = ctx.scoping().symbol_declaration(symbol_id); + let decl_node = ctx.nodes().get_node(decl_id); + + // Check if this is a VariableDeclarator with ObjectPattern + if let AstKind::VariableDeclarator(var_decl) = decl_node.kind() { + // Check if init is an identifier imported from React + if let Some(Expression::Identifier(init_ident)) = var_decl.init.as_ref() { + // Check if the init identifier is imported from 'react' module + return import_matcher(ctx, init_ident.name.as_str(), REACT_MODULE); } } }