diff --git a/crates/oxc_linter/src/rules/react/jsx_key.rs b/crates/oxc_linter/src/rules/react/jsx_key.rs index 1c7efe38a..4c173f6a2 100644 --- a/crates/oxc_linter/src/rules/react/jsx_key.rs +++ b/crates/oxc_linter/src/rules/react/jsx_key.rs @@ -269,6 +269,9 @@ fn check_jsx_element_is_key_before_spread<'a>(jsx_elem: &JSXElement<'a>, ctx: &L fn check_jsx_fragment<'a>(node: &AstNode<'a>, fragment: &JSXFragment<'a>, ctx: &LintContext<'a>) { if let Some(outer) = is_in_array_or_iter(node, ctx) { + if is_within_children_to_array(node, ctx) { + return; + } ctx.diagnostic(gen_diagnostic(fragment.opening_fragment.span, &outer)); } } @@ -487,6 +490,14 @@ fn test() { React.Children.toArray([1, 2 ,3].map(x => )); "#, r"React.Children.toArray([1, 2 ,3].map(x => ));", + r"{React.Children.toArray(items.map((item) => { + return ( + <> + {item} + + ); + }))} + ", ]; let fail = vec![