-
Notifications
You must be signed in to change notification settings - Fork 24
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
Introduce importOrderBuiltinModulesToTop
for Node Builtins
#10
Conversation
# Conflicts: # src/utils/__tests__/get-sorted-nodes.spec.ts # src/utils/get-sorted-nodes.ts
The commit itself looks good, it's only a very small change. @IanVS Have you checked if this works for prefixed modules such as Other than that, my very personal opinion is that a prettier plugin should be opinionated in the same way prettier is and have as few options as possible. But this plugin doesn't really follow that philosophy. I took a quick look at https://www.npmjs.com/package/@ianvs/prettier-plugin-sort-imports and I'd say there are enough downloads we can't just introduce a breaking change. In the long term we should decide if we want to tend towards "many options for configurability" or "few options with an opinionated sort order" -- we could remove options in a major release. What are you thoughts about this? I also wonder what users are thinking in this regard. But in short, if we add this without a new major release, it needs to be an option that defaults to false. And a major release imo only makes sense if we decided to set a new goal for this plugin and start removing other option. |
Thanks @blutorange. I've added some more tests as you suggested. I agree with you about not making breaking changes outside of majors. It annoys me that prettier itself makes breaking changes in minors, and I don't want to follow that pattern. I think one thing we should consider is that this plugin is changing the actual AST, rather than only formatting like prettier does. So, there's a chance we do need to allow a few more options than a purely-formatting tool would. But where it makes sense, I think we should avoid options. I'd like to make this behavior the default in the next major version, and maybe even remove the option entirely, unless we hear that it causes big problems for folks. I think this is ready for another review, when you have time. Thanks again! |
Semver only works if people actually stick to it, so yes, sounds like a good idea to me I also don't really like the |
importOrderBuiltinModulesToTop
for Node BuiltinsimportOrderBuiltinModulesToTop
for Node Builtins
I'm going to merge this so I can rebase #12 on main. I think I got an approval above, but if you want any changes, @blutorange, let me know and I'll open another PR. |
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.