dprint-plugin-typescript
dprint-plugin-typescript copied to clipboard
Support sorting imports "naturally"
Given:
import {
transformDeclarations,
transformECMAScriptModule,
Transformer,
TransformerFactory,
transformES5,
transformES2015,
transformES2016,
transformES2017,
transformES2018,
transformES2019,
transformES2020,
} from "./_namespaces/ts";
eslint-plugin-simple-import-sort sorts these like the above, which is to say naturally. TS also does this (with some configuration). dprint formats these in string order only:
import {
transformDeclarations,
transformECMAScriptModule,
Transformer,
TransformerFactory,
transformES2015,
transformES2016,
transformES2017,
transformES2018,
transformES2019,
transformES2020,
transformES5,
} from "./_namespaces/ts";
It'd be great if natural sorting were an option. I'm not sure how feasible that is cross-platform, but both eslint-plugin-simple-import-sort and TS use Intl.Collator to do this, so maybe it's standardish.
I think that the collator from ICU4X could be used for this, I believe that it has the same behaviour as JS Intl.Collator