IanVS / prettier-plugin-sort-imports

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

importOrderSeparation #117

Closed SalahAdDin closed 1 year ago

SalahAdDin commented 1 year ago

Is your feature request related to a problem? In the original library, it was easy to get blank lines between import groups, but in this one, you have to add blank lines to the import groups array which is unesthetic and less intuitive.

Describe the solution you'd like The Trivago library does include a setting that adds blank lines between import groups by default, and it makes easier and more intuitive the configuration.

importOrderSeparation type: boolean default value: false A boolean value to enable or disable the new line separation between sorted import declarations group. The separation takes place according to the importOrder. "importOrderSeparation": true,

It would be nice to have this setting back to this new library.

Describe alternatives you've considered I'm thinking of coming back to the old library since the blank lines setting is very useful and from all features introduced by this library, I don't use anyone.

Additional context Add any other context or screenshots about the feature request here.

IanVS commented 1 year ago

Hi there @SalahAdDin, thanks for the suggestion. The trivago version does not support custom blank lines like this one does, which is why it needs to have importOrderSeparation. Our approach here is to try to make importOrder as flexible as possible, so that it's not necessary to have a bunch of extra options that you have to learn and configure. After all, prettier itself only has a handful of configuration options.

So, it's entirely possible to achieve what you want, by adding blank groups (like "") to your importOrder between your other items. That is the best way to achieve the previous importOrderSeparation. If you share your config, I can give an example of what it would look like.

Edit: I re-read your issue, and see that you are aware of how to achieve it. I'm sorry that you think it's not as intuitive, but we won't be adding back the importOrderSeparation. We think it's important to keep the number of options low.

fbartho commented 1 year ago

I concur with @IanVS. We’re more flexible than trivago in this case, while having fewer options, but I’m sorry if that breaking change doesn’t match your preference.