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
jsx-sort-props rule is not working as it should #1692
Comments
It would be dangerous to enforce object spread props on any particular order, as you might intend props before it to be overridden, and props after it to override. The collision between options sounds like it might be a bug. |
We can discard issue about object spread props, but what about |
What error do you get from your example? |
As I mentioned before |
In your example, the shorthand prop is on the bottom. Can you provide example code and config, combined with actual and expected output? |
Hey I just stumbled over this as well. I figured I just add some requested data: Example Code + ConfigCodeimport React from 'react';
export const Test = () => (
<p z="test" a />
); Config{
"root": true,
"extends": ["eslint:recommended", "plugin:react/recommended"],
"parser": "babel-eslint",
"parserOptions": {
"ecmaFeatures": {
"experimentalObjectRestSpread": true,
"jsx": true
},
"sourceType": "module"
},
"plugins": [
"react"
],
"rules": {
"react/jsx-sort-props": [2, {
"reservedFirst": true,
"shorthandLast": true
}
}
} Expected OutputNote: I run
Actual Output
"Interesting" ObservationIf I only supply the Example working config for only shorthand rule: ...
"rules": {
"react/jsx-sort-props": [2, {
"shorthandLast": true
}]
} |
My own opinion, this rule should be remade to be similar to |
@zalishchuk can you elaborate a little on what you mean specifically? Do you mean the documentation, the rule's structure, the validation algorithm? I'm just curious... |
@fleischie I want the rule configuration to look like this. "react/jsx-sort-props": ['error', {
order: [
'reserved',
'everything-else',
'callbacks',
'shorthands',
]
}] |
Hmm, yes. And the |
Before I dive deeper into this issue code-wise, I still have some questions as this will be a breaking change (the configuration structure will drastically change):
Any additional pointers will be gladly taken. |
We should avoid a breaking change. |
Rule configuration:
As a result
callbacksLast
,shorthandLast
options are overridden bynoSortAlphabetically
, so props are sorting only by alphabet ignoring shorthands at the end. Also, how can I reach this sort order:Example:
The text was updated successfully, but these errors were encountered: