-
-
Notifications
You must be signed in to change notification settings - Fork 18
[feat] Sort key before spread #1087
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
This feature request has been accepted, I will add a |
Hmm... Why not just port |
There are already multiple rules to sort props. These correctly allow users to sort props before or after JSX spread syntax. This is important, because spread syntax changes the order in which the props override each other. The |
Then why it must be implemented here instead of an option of |
Because this is the only way to correctly set the severity of the two types of problems mentioned above under the ESLint plugin system, which allows setting |
Why it/they should be considered two types of problems at the first place? There are many rules have different options, and different options share same severity, we don't provide different rules for each of them only for different severities? |
This is exactly the bad practice, caused by a lack of understanding of the linter tool. |
Hah? The current implementation is exactly the bad practice without cooperations with other plugins IMO. But well, you're the boss here. |
The project was created with the philosophy of "Rules Over Options", and many of the achievements made so far have benefited from this choice. |
Each rule should have a single purpose. Make multiple rules work together to achieve more complex behaviors instead of adding endless options to a single rule. IMO, This is how plugins should cooperate. |
That's exactly what I mean "you're the boss here", you can have your own philosophy, that's totally fine, although anyone else like me might disagree. |
AKA "composition over configuration" 💯 |
It's definitely not, every single rule needs to be enabled specifically. 😅 |
In most scenarios this is a benefit rather than a drawback. When a single rule does too much, the rule itself becomes a "plugin", and its messages and options act as the actual "rule". However, messages and options are not first-class citizens under the ESLint plugin system and config system, but rules are. |
Describe the problem
There are already rules to sort props.
perfectionist/sort-jsx-props
@stylistic/jsx/jsx-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 playgroundIf the
key
prop is before any spread props, it is passed as thekey
argument of the_jsx
/_jsxs
/_jsxDev
function. But if thekey
prop is after spread props, The compiler usescreateElement
instead and passeskey
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.
The text was updated successfully, but these errors were encountered: