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

Option for disabling character class and flag sorting in transformations #199

Open
brettz9 opened this issue Nov 30, 2019 · 2 comments
Open

Comments

@brettz9
Copy link
Contributor

brettz9 commented Nov 30, 2019

Hi,

While I expect this might not be trivial given that the sorting presumably helps in building ranges, it would be very useful if this resorting could be optionally disabled.

In the project, eslint-plugin-unicorn, regexp-tree is being used to otherwise very helpful effect in the rule regex-shorthand (as per sindresorhus/eslint-plugin-unicorn#453 ). This linting rule lints source files--files which are more likely than say distribution files--to call for preserving the original sorting order, whether for better readability or maintainability (e.g., [aAbBcC]) or for causing or necessitating additional modifications of regular expressions per the linting rule any time something might be manually added or changed in a character class to break the code point sorting pattern--especially given that users are not likely to always know or wish to spend time looking up code point values for the characters they are adding.

Similarly, the auto-sorting of flags forces source into enforcing a particular sequence of flags.

Thanks for your consideration!

@brettz9 brettz9 changed the title Option for disabling character class sorting in transformations Option for disabling character class and flag sorting in transformations Dec 2, 2019
@voxpelli
Copy link
Contributor

voxpelli commented Dec 3, 2019

Adding parts of my comment from the other issue:

I agree that this is problematic.

One part of it is that different languages sort characters in different ways. Eg. in Swedish åäö is last in the alphabet and in that order and this rule eg. wants to resort åä to äå. To makes matter even more complicated, German sorts those letters after their dot-less equivalents, so ä after a and ö after o – so one universal true rule is not really possible when sorting purely on letters, unless one wants to enforce a "true" sorting upon everyone else.

@DmitrySoshnikov
Copy link
Owner

Thanks, this makes sense. I have merged the PR, and also we can provide support for more granular options per-transform. E.g. for preserving the order in specific transform, instead of just fully disabling it. As a first step though, having the blacklist is a good option.

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

No branches or pull requests

3 participants