package-qualified imports are sorted poorly
Closed this issue · 4 comments
Ormolu ignores the package name when sorting imports.
import ElidedPackage
import "otherpackage" Baz
import "this" Bar
import "this" Foo
import "whatpackage" Meh
gets re-ordered by Ormolu to
import "this" Bar
import "otherpackage" Baz
import ElidedPackage
import "this" Foo
import "whatpackage" Meh
I think imports should be sorted by package name then module. Imports without package qualifiers can be sorted as if the package were ""
.
I think my ideal version would also separate out the special "this"
package, rather than putting it among the “t”s. And maybe even include blank lines between the three groups (or perhaps just between "this"
and the other imports, to indicate that "this"
is handled specially:
import ElidedPackage
import "otherpackage" Baz
import "whatpackage" Meh
import "this" Bar
import "this" Foo
This was changed in #905 (grouping, but not with newlines). Can you try using Ormolu >=0.5.1.0? There, the output of your snippet should be
import ElidedPackage
import "otherpackage" Baz
import "this" Bar
import "this" Foo
import "whatpackage" Meh
Ah, sorry. This is fine for me, then.
I do think separating out "this"
would still be good (because it’s not actually a package name), but the blank lines I can take or leave.
I do think separating out
"this"
would still be good (because it’s not actually a package name)
Yes, I think that is a good point 👍