Closed james-elicx closed 2 months ago
To match prettier's opinionated ethos, while also making sure this plugin is as easy to use as possible, and to simplify maintenance, we have severely limited the number of configuration options exposed by this plugin. In other words: I don't foresee us currently adding this feature, sorry.
Obviously it's not my call alone, but I did want to explain my opinion.
Note: you may find this interesting: there is a setting to group together Type-imports at the top level, though that doesn't apply inside a single import expression!
I see, thanks for the added context. It makes sense.
We have a mix in our codebase of type imports being separate and type imports being mixed with value imports. The eslint plugin for sorting imports we use puts those type specifiers at the start in the type-value mixed imports, whereas this puts it at the end. So if we were to look at migrating to this instead of the eslint plugin (which I would quite like), we'd need to change the format of the imports in our monorepo first, or move to not using the mixed type-value imports, which would also be a decent-sized change.
Hi thanks for explaining. I don't quite understand this part though.
we'd need to change the format of the imports in our monorepo first, or move to not using the mixed type-value imports
This prettier plugin will do either of those things for you, so why would you need to do one of them first?
we'd need to change the format of the imports in our monorepo first, or move to not using the mixed type-value imports
This prettier plugin will do either of those things for you, so why would you need to do one of them first?
the amount of codeowners and sheer number of files in a large monorepo with many teams means it's not an easy job to switch over. Unless you disable prettier for different directories so you can do a staged roll-out by different codeowners, you have to do one of them first.
OK thanks for explaining. As @fbartho said, we are intentionally keeping the number of options in this plugin limited, especially for style preferences like this.
If you're rolling this out in a large monorepo, you can take the same approach as Slack and start off disabling it with importOrder: []
in any projects you do not want it to be enabled inside (https://github.com/IanVS/prettier-plugin-sort-imports/issues/159).
Or as another alternative, you could consider patching this project with pnpm patch
or patch-package
, and change the order of these items: https://github.com/IanVS/prettier-plugin-sort-imports/blob/fef70a61af77f70919742cd4ae335af3edd2a027/src/constants.ts#L21-L24
That should cause type imports to be placed first, I believe.
Is your feature request related to a problem?
It would be great to have control over whether the
type
imports in a mixed type-value import appear at the start or the end of the import. At the moment, they seem to be re-ordered to the end. I would like to be able to configure this.Describe the solution you'd like
Ability to have the type specifier imports before the value imports through a configuration option.
Additional context
Input:
Current output:
Desired output: