prettier-plugin-sort-imports icon indicating copy to clipboard operation
prettier-plugin-sort-imports copied to clipboard

Functionality to move NodeJS builtin modules to the top

Open karlhorky opened this issue 4 years ago • 6 comments

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?

karlhorky avatar Aug 19 '21 08:08 karlhorky

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.x as 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.

ayusharma avatar Aug 26 '21 14:08 ayusharma

Nice, thanks for the reply!

Would suggest using the following replacements for the naming:

  • builtin instead of inbuilt
  • ToTop instead of AtTop
  • Node instead of NodeJS

eg. sortNodeBuiltinModulesToTop

karlhorky avatar Aug 26 '21 16:08 karlhorky

Any update on this? If not, I could take a look.

kevinwolfcr avatar Jan 24 '22 19:01 kevinwolfcr

Howdy! I've picked this up and a PR will be incoming momentarily.

nickhudkins avatar Apr 28 '22 16:04 nickhudkins

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

IanVS avatar Jul 25 '22 15:07 IanVS

Maybe it could be a importOrder classifier like <THIRD_PARTY_MODULES>?

mon-jai avatar Feb 09 '23 11:02 mon-jai