prettier-plugin-sort-imports
prettier-plugin-sort-imports copied to clipboard
Functionality to move NodeJS builtin modules to the top
Hi there, thanks for this package, really cool! Will consider recommending it to our bootcamp students at @upleveled.
One suggestion that came to mind would be to make it the default sort order to sort imports using the new node: scheme / prefix to the top. What do you think?
Hi @karlhorky. Thank you so much for the message.
We can implement this feature in the next upcoming release. If someone would like to contribute and implement this, that would be great. Please keep the following things in mind.
- You can implement an API in the options, for this functionality. e.g.
sortInbuiltNodeJSMoulesAtTop. - Create a PR to
v3.xas the base branch. - You can detect node js inbuilt modules using
require("module").builtinModules.
Feel free to drop a message if something is not clear.
Nice, thanks for the reply!
Would suggest using the following replacements for the naming:
builtininstead ofinbuiltToTopinstead ofAtTopNodeinstead ofNodeJS
eg. sortNodeBuiltinModulesToTop
Any update on this? If not, I could take a look.
Howdy! I've picked this up and a PR will be incoming momentarily.
In case anyone here is still looking for this, until this project adds support, you could use my fork, which is published on npm and supports this feature: https://github.com/IanVS/prettier-plugin-sort-imports#importorderbuiltinmodulestotop
Maybe it could be a importOrder classifier like <THIRD_PARTY_MODULES>?