IanVS / prettier-plugin-sort-imports

An opinionated but flexible prettier plugin to sort import statements
Apache License 2.0
984 stars 25 forks source link

Add importOrderCaseInsensitive option again #151

Open angrybacon opened 7 months ago

angrybacon commented 7 months ago

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

IanVS commented 3 months ago

Leaving this open so that others can vote with đź‘Ť, and we'll consider it depending on the demand.

jar145 commented 3 months ago

I'm curious why this was removed in the first place? I'm happy to make a PR if time is the issue.

IanVS commented 3 months ago

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.

acnebs commented 3 weeks ago

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:

import {
  faAngleLeft,
  faAngleRight,
  faArrowDown,
  faArrowLeft,
  faArrowRight,
  faArrowsV,
  faArrowUp,
  faSearch,
  faSmile,
  faTvRetro,
} from '@fortawesome/pro-regular-svg-icons';

@ianvs/prettier-plugin-sort-imports sorts the faArrowsV before the faArrowsUp, which I think is very strange when you look at it. It makes much more sense for the "arrow" icon to be sorted with the other "arrow" (singular) icons, and then for the "arrows" icon to come after (or before), the point is that case-insensitivity to me seems like a very strange default.

tony commented 1 week ago

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.

Are you sure that applies in this case?

Using capitalization to indicate the type of symbol—such as STATIC, ClassOrComponent, and variableOrInstance—can lead to "disorganized" symbols:

-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!

IanVS commented 1 week ago

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.