Description
Describe the problem
There are already rules to sort props.
These are stylistic rules. So they rightfully don’t sort props before or after prop spread syntax. However, when using the JSX automatic runtime, key
is a special attribute in the JSX transform. See the Babel repl and TypeScript playground
If the key
prop is before any spread props, it is passed as the key
argument of the _jsx
/ _jsxs
/ _jsxDev
function. But if the key
prop is after spread props, The compiler uses createElement
instead and passes key
as a regular prop.
Describe the solution you'd like
It would be useful to have a rule that warns the user if the key prop appears after JSX spread syntax.
Alternatives considered
It could also be incorporated into @eslint-react/no-implicit-key
.
Additional context
The key doesn’t have to be first, only before JSX spread syntax. Other rules can take care of sorting.