Skip to content

Conversation

@nickhudkins
Copy link

This change introduces a new configuration option to sort Node builtins to the top of all imports 🎉

IanVS added a commit to IanVS/prettier-plugin-sort-imports that referenced this pull request May 12, 2022
This is a cherry-pick of a PR from @nickhudkins to the upstream project: trivago/prettier-plugin-sort-imports#150, adjusted slightly to work within the rule of this project to not sort beyond side-effect import groups.  

@blutorange what do you think of this?  I'm reluctant to add another option, but if we changed this without an option it would be a breaking change.  I don't have a strong opinion one way or the other, but personally I do like sorting builtins to the top, so it would be nice to have some way to do it.

Co-authored-by: Nick Hudkins <[email protected]>
* where the not matched imports should be placed
*/
export const THIRD_PARTY_MODULES_SPECIAL_WORD = '<THIRD_PARTY_MODULES>';
export const BUILTIN_MODULES = builtinModules.join('|');
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a bit of warning, this regex needs to be a bit more strict, see IanVS/prettier-plugin-sort-imports#17 for the implementation in a fork.

@mon-jai
Copy link

mon-jai commented Feb 23, 2023

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

@vladislavarsenev
Copy link
Collaborator

Hey @nickhudkins! thank you for PR, it was implemented in #381 and merged to 6th version. It's about to release soon!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants