mirror of
https://github.com/danbulant/oxc
synced 2026-05-19 12:19:15 +00:00
fix(linter): jsx-key: handle anonymous functional components in arrays that have a function body (#1983)
Closes #1982
This commit is contained in:
parent
78b427bc50
commit
d4acd140ad
1 changed files with 10 additions and 3 deletions
|
|
@ -83,7 +83,6 @@ fn is_in_array_or_iter<'a, 'b>(
|
|||
|
||||
let mut is_outside_containing_function = false;
|
||||
let mut is_explicit_return = false;
|
||||
let mut is_arrow_expr_statement = false;
|
||||
|
||||
loop {
|
||||
let Some(parent) = ctx.nodes().parent_node(node.id()) else {
|
||||
|
|
@ -92,7 +91,7 @@ fn is_in_array_or_iter<'a, 'b>(
|
|||
|
||||
match parent.kind() {
|
||||
AstKind::ArrowExpression(arrow_expr) => {
|
||||
is_arrow_expr_statement = matches!(
|
||||
let is_arrow_expr_statement = matches!(
|
||||
arrow_expr.body.statements.first(),
|
||||
Some(Statement::ExpressionStatement(_))
|
||||
);
|
||||
|
|
@ -126,7 +125,7 @@ fn is_in_array_or_iter<'a, 'b>(
|
|||
is_outside_containing_function = true;
|
||||
}
|
||||
AstKind::ArrayExpression(_) => {
|
||||
if is_arrow_expr_statement {
|
||||
if is_outside_containing_function {
|
||||
return None;
|
||||
}
|
||||
|
||||
|
|
@ -392,6 +391,14 @@ fn test() {
|
|||
(Component) => <div><Component /></div>
|
||||
];
|
||||
",
|
||||
r"
|
||||
MyStory.decorators = [
|
||||
(Component) => {
|
||||
const store = useMyStore();
|
||||
return <Provider store={store}><Component /></Provider>;
|
||||
}
|
||||
];
|
||||
",
|
||||
];
|
||||
|
||||
let fail = vec![
|
||||
|
|
|
|||
Loading…
Reference in a new issue