-
Notifications
You must be signed in to change notification settings - Fork 25
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
Add importOrderCaseInsensitive option again #151
Comments
Leaving this open so that others can vote with 👍, and we'll consider it depending on the demand. |
I'm curious why this was removed in the first place? I'm happy to make a PR if time is the issue. |
It was removed because there were a ton of options previously, which goes against the philosophy of prettier. There more options there are, the more you have to think about decisions when setting it up, and the more complex the codebase becomes. |
I not only want case-sensitivity, but also think that this should be the default. Here is a prime example of why I think this is the case:
|
Are you sure that applies in this case? Using capitalization to indicate the type of symbol—such as -import { Comp, BOOL_COMP, TEXT_COMP } from './lib/constants'
+import { BOOL_COMP, Comp, TEXT_COMP } from './lib/constants' @IanVS Are you open to bringing this option back? Seems to have a decent number of 👍's. Would this package being funded change anything? I think a lot of users appreciate your effort on the package in general! |
No, funding isn't the main concern here. It does seem like this has gotten some interest, so I'm open to re-adding the option. I wouldn't want to change the default, to avoid a breaking change, but I think adding in the option would be reasonable at this point. I'll be happy to review a PR if anyone would like to submit one. It should be fairly straightforward to look at the code we used to have which was removed for the last breaking release. |
Implements a custom natural sort algorithm which allows for numeric natural sorting while also sorting all uppercase letters before all lowercase letters, which is the desired behavior here. For example, when `importOrderCaseSensitive` is false (the default): ```js import ExampleComponent from './ExampleComponent'; import ExamplesList from './ExamplesList'; import ExampleWidget from './ExampleWidget'; ``` Compared with `"importOrderCaseSensitive": true`: ```js import ExampleComponent from './ExampleComponent'; import ExampleWidget from './ExampleWidget'; import ExamplesList from './ExamplesList'; ``` Closes IanVS#151
Implements a custom natural sort algorithm which allows for numeric natural sorting while also sorting all uppercase letters before all lowercase letters, which is the desired behavior here. For example, when `importOrderCaseSensitive` is false (the default): ```js import ExampleComponent from './ExampleComponent'; import ExamplesList from './ExamplesList'; import ExampleWidget from './ExampleWidget'; ``` Compared with `"importOrderCaseSensitive": true`: ```js import ExampleComponent from './ExampleComponent'; import ExampleWidget from './ExampleWidget'; import ExamplesList from './ExamplesList'; ``` Closes IanVS#151
One suggestion here - would it make sense to allow only applying case-sensitivity on the imported values (i.e. not the import paths)? I think its much more common to want this applied to imported values, which is what this issue originally asked about, and what @acnebs provided the example for |
@alex-statsig I thought about that, but the same logic applies to paths. e.g. with the example I used in the commit message. import ExampleComponent from './ExampleComponent';
import ExamplesList from './ExamplesList';
import ExampleWidget from './ExampleWidget'; but when sorted with case sensitivity: import ExampleComponent from './ExampleComponent';
import ExampleWidget from './ExampleWidget';
import ExamplesList from './ExamplesList'; To me, the case-sensitive sort makes a lot more sense. After all, in Javascript/Typescript, CamelCase is used basically everywhere (and camel case is really the motivating reason behind the implementation of this case sensitive sort). |
There's value in sorting uppercase first: constants, constructors and functions become sorted in that order.
Support for case sensitive sorting was dropped here #63
The text was updated successfully, but these errors were encountered: