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

Add a groupRule to default options for `node:` prefixed builtin modules #48

Closed karlhorky closed 3 years ago

karlhorky commented 3 years ago

Is your feature request related to a problem? Please describe.

The new node: prefix for module specifiers for builtin / core modules (currently in v16, but will be backported) is not specified in the groupRules default configuration, which means that it will be sorted inline around "n".

Describe the solution you'd like

Add a group rule at the beginning for module specifiers starting with node:

 "tsImportSorter.configuration.groupRules": [
+  "^node:",
   "^react(-dom)?$",
   "^@angular/",
   "^vue$",
   {},
   "^[@]",
   "^[.]"
 ],

Describe alternatives you've considered

Adding the group rule at some other position in the list

daidodo commented 3 years ago

@karlhorky - Thanks for the feedback! This is a good feature! One question: Are node: imports BEFORE or AFTER React/Angular/Vue by default? I'm a bit in favour of AFTER because it's aligned with current behaviour.

Happy to hear your thoughts!

karlhorky commented 3 years ago

I guess I don't have strong feelings either way (since it is user-configurable anyway). Usually in my projects, I have Node core modules at the very top.

But as you said, if they are below React / Angular / Vue in the current default extension configuration, then it would be less of a breaking change to leave them where they are.

daidodo commented 3 years ago

@karlhorky - Sorry for the late response! I've released v7.4.0 to address the issue. Please have a look and tell me if you have any questions.

Thanks!

karlhorky commented 3 years ago

No worries, not super urgent anyway :)

Ah, can you push to GitHub as well? I'll take a look, thanks!

daidodo commented 3 years ago

Sure. The main changes are in a commit from anonther repo https://github.com/daidodo/format-imports.

karlhorky commented 3 years ago

Great, changes look good to me, thanks! 🙌 Closing.