Replies: 1 comment
-
After creating, seems like I've found this is a almost an exact duplicate of #645. I will close my discussion! |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Jump to https://github.com/lydell/eslint-plugin-simple-import-sort for a possibly quicker understanding
Current Behaviour: Biome currently sorts imports just fine, and avoids the issue of breaking side-effect imports by allowing you to group things manually by inserting linebreaks. This works fine, but since the developer handles all the groups/linebreaks manually, there's no consistency enforced on groupings/linebreaks by the formatter. Consider a large project where lots of developers work on different files, and all decide different ways to insert new linebreaks, which lacks consistency and opinionated "one-way-to-do-it" formatting. Someone might change the groupings for no real reasons in a PR, and change them back, etc. Maybe someone groups imports by feature, some by function, some fully alphabetically, etc.
Goal: My goal is to have almost fully deterministic, one-way method of grouping the imports with no room for arguing over formatting, and a full consistency over a codebase. The current behaviour is unopinionated and leaves too much formatting decisions to humans.
Proposal: Don't use manually inserted linebreaks, instead just 'dont apply' the sorting to any unnamed imports. Allowing you to manually put side-effecting ones particular ones where needed. See this example for how everything may be grouped (basically builtins->npm packages->internal imports). The exact mechanics and specifics (e.g. do internal relative/absolutes get grouped separately) can be up for debate, I don't think it has to be the same as this plugin.
Ideally, I think biome should take this behaviour by default (i.e by default be more opinionated, and let people subtract what they want off that, i.e reverting to the current behaviour by enabling a
manualGrouping: true
option.Example
Biome is an opinionated formatter. In an ideal world, that means Biome assumes there is only one correct way to format things and will enforce that style at all times. No matter the project, no matter the setup, code formatted by Biome will always look the same. From another perspective, Biome is its own automatic style guide, not a tool for implementing other style guides.
- https://biomejs.dev/formatter/option-philosophy/I think the proposal also helps biome to more closely align with its' philosophy.
Beta Was this translation helpful? Give feedback.
All reactions