Skip to content
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 sorts differently when using Czech language #3613

Closed
2 tasks done
googol7 opened this issue Jul 28, 2023 · 8 comments
Closed
2 tasks done

jsx-sort-props sorts differently when using Czech language #3613

googol7 opened this issue Jul 28, 2023 · 8 comments
Labels

Comments

@googol7
Copy link

googol7 commented Jul 28, 2023

Is there an existing issue for this?

  • I have searched the existing issues and my issue is unique
  • My issue appears in the command-line and not only in the text editor

Description Overview

When working with Windows and using the Czech language as the "Windows display language", it sorts differently.

English:

checked={true}
data-testid="test"
name="test"

Czech:

data-testid="test"
checked={true}
name="test"

This is because the letter "Ch" comes after the letter "D" in the Czech alphabet.

See: https://en.wikipedia.org/wiki/Czech_orthography#Alphabet

Affected rule: https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/jsx-sort-props.md

image

Expected Behavior

It should work the same in all languages because the programming language is English and not Czech.

eslint-plugin-react version

7.32.2

eslint version

v8.12.0

node version

v16.15.1

@googol7 googol7 added the bug label Jul 28, 2023
@ljharb
Copy link
Member

ljharb commented Jul 28, 2023

This is intentional; it's assumed everyone working on the same project is using the same locale.

@googol7
Copy link
Author

googol7 commented Jul 28, 2023

This is intentional; it's assumed everyone working on the same project is using the same locale.

I don't think that's practical for international teams.

@ljharb
Copy link
Member

ljharb commented Jul 28, 2023

The rule takes a locale option if you want to avoid it changing based on the user's locale, which i think makes this a duplicate of #3002.

googol7 added a commit to googol7/eslint-config-molindo that referenced this issue Jul 28, 2023
Sorting shall work the same for different locales.

See jsx-eslint/eslint-plugin-react#3613
@googol7
Copy link
Author

googol7 commented Jul 28, 2023

@ljharb Thanks for pointing this out. I think that the default should be

locale: "en",

If a team decides to use another locale, then that’s fine. By providing a default, you make sure that everybody gets the same sorting result.

@ljharb
Copy link
Member

ljharb commented Jul 28, 2023

That would be a breaking change, so it’s unlikely to ever happen - and it would be a bit anglocentric i think?

@googol7
Copy link
Author

googol7 commented Jul 29, 2023

As properties are named in English, I guess it’s only logical to have the default locale: "en".

@ljharb
Copy link
Member

ljharb commented Jul 29, 2023

There are plenty of codebases where that’s not the case, even though the language uses English names.

Either way, we’re not doing a major bump any time soon, and the locale option i think answers your question.

@ljharb ljharb closed this as completed Jul 29, 2023
@googol7
Copy link
Author

googol7 commented Jul 31, 2023

I can understand that a breaking change is not good. It was quite tedious for us to find the reason for the different sorting of the properties.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

No branches or pull requests

2 participants