daidodo / format-imports-vscode

Format imports and exports for JavaScript and TypeScript in VS Code.
https://marketplace.visualstudio.com/items?itemName=dozerg.tsimportsorter
MIT License
62 stars 5 forks source link

Export sorting doesn't work the same as Import sorting. #43

Closed Torhal closed 3 years ago

Torhal commented 3 years ago

I had expected exports to be sorted by the same criteria as imports, but discovered that only the barrel names are sorted.

Given

export * from "./t-named-file";
export * from "./z-named-file";
export * from "./a-named-file";

Nothing happens. If these were imports instead of exports, you'd see:

import * as aName from "./a-named-file";
import * as tName from "./t-named-file";
import * as zName from "./z-named-file";

Given:

export { Foo, Baz, Bar  } from "./some-file";

The export is correctly sorted as:

export { Bar, Baz, Foo } from "./some-file";

This is correct, as it is what also happens for imports.

daidodo commented 3 years ago

@Torhal, thanks for the feedback!

Details about how exports are formatted can be found here. And sorting exports by paths is not supported yet because the requirement isn't clear.

But I'm happy to discuss any suggestions from you.

daidodo commented 3 years ago

@Torhal - I'll close this issue since there isn't enough response to start a discussion. But feel free to re-open it once you have something in mind.