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
react/jsx-sort-props + {ignoreCase: false} now ignores case when sorting props #2530
Comments
This definitely seems like an unexpected change. |
Specifically, we should probably only use localeCompare when ignoreCase is true? |
@ljharb any news on this one? |
No, "help wanted" means it's awaiting a PR. |
Hi @hawkrives , |
@tanmoyopenroot we must depend on localeCompare whenever possible since english isn't the only language in the world. |
@ljharb But each character in a string in any language will be compared in |
If that were true, there'd be no point in the localeCompare method existing. |
I will try to fix it using |
Fixes jsx-eslint#2381. Fixes jsx-eslint#2530. Co-authored-by: tanmoyopenroot <tanmoy.openroot@gmail.com> Co-authored-by: Jordan Harband <ljharb@gmail.com>
I've found an unexpected(?) change that stems from #2391.
With
{ignoreCase: false}
, which according to the docs should take case into account when sorting the props, the above example now expectsname
to be sorted beforeNumber
.I know why it sorts the way it does: #2391 switched to using
String#localeCompare
, which does…Looking at the
lib/rules/jsx-sort-props.js
code, I'm not sure what changes would be required to accommodate both this issue and #2381, unfortunately.So, the crux of this issue is: is this an unexpected change, or should I alter my expectations and update the documentation to reflect this behavior?
The text was updated successfully, but these errors were encountered: