mirror of
https://github.com/danbulant/oxc
synced 2026-05-24 12:21:58 +00:00
fix(linter): incorrect reporting for jsx_key (#1020)
tested on a different repo and noticed an issue (despite passing all of
the eslint test cases)
If we are in the following scenario:
```tsx
const columns: ColumnDef<User>[] = [
{
accessorKey: 'firstName',
header: ({ column }) => <DataTableColumnHeader column={column} title="First Name" />,
cell: ({ row }) => <div>{row.getValue('firstName')}</div>,
enableSorting: true,
enableHiding: false,
},
]
```
Previously an error would be reported however it did not make sense to
as the object has to be mapped again before it is displayed in react
(hence lets check there instead)
This commit is contained in:
parent
5e083b156c
commit
ee134f022c
1 changed files with 35 additions and 2 deletions
|
|
@ -79,6 +79,15 @@ fn is_in_array_or_iter<'a, 'b>(
|
|||
};
|
||||
|
||||
match parent.kind() {
|
||||
AstKind::ArrowExpression(_) | AstKind::Function(_) => {
|
||||
let Some(parent) = ctx.nodes().parent_node(parent.id()) else {
|
||||
return None;
|
||||
};
|
||||
|
||||
if let AstKind::ObjectProperty(_) = parent.kind() {
|
||||
return None;
|
||||
}
|
||||
}
|
||||
AstKind::ArrayExpression(_) => return Some(InsideArrayOrIterator::Array),
|
||||
AstKind::CallExpression(v) => {
|
||||
let callee = &v.callee.without_parenthesized();
|
||||
|
|
@ -94,8 +103,9 @@ fn is_in_array_or_iter<'a, 'b>(
|
|||
return None;
|
||||
}
|
||||
AstKind::JSXElement(_) | AstKind::JSXOpeningElement(_) => return None,
|
||||
_ => node = parent,
|
||||
_ => {}
|
||||
}
|
||||
node = parent;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -290,10 +300,33 @@ fn test() {
|
|||
}
|
||||
|
||||
export const clusterFrameMap = observable.map<string, ClusterFrameInfo>();
|
||||
|
||||
"#,
|
||||
None,
|
||||
),
|
||||
(
|
||||
r#"
|
||||
const columns: ColumnDef<User>[] = [{
|
||||
accessorKey: 'lastName',
|
||||
header: ({ column }) => <DataTableColumnHeader column={column} title="Last Name" />,
|
||||
cell: ({ row }) => <div>{row.getValue('lastName')}</div>,
|
||||
enableSorting: true,
|
||||
enableHiding: false,
|
||||
}]
|
||||
"#,
|
||||
None,
|
||||
),
|
||||
(
|
||||
r#"
|
||||
const columns: ColumnDef<User>[] = [{
|
||||
accessorKey: 'lastName',
|
||||
header: function ({ column }) { return <DataTableColumnHeader column={column} title="Last Name" /> },
|
||||
cell: ({ row }) => <div>{row.getValue('lastName')}</div>,
|
||||
enableSorting: true,
|
||||
enableHiding: false,
|
||||
}]
|
||||
"#,
|
||||
None,
|
||||
),
|
||||
];
|
||||
|
||||
let fail = vec![
|
||||
|
|
|
|||
Loading…
Reference in a new issue