Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Introduces importOrderBuiltinModulesToTop for Node Builtins #71 #150

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

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]>
@@ -12,6 +13,7 @@ export const newLineCharacters = '\n\n';
* 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>?

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.

4 participants