Replies: 3 comments 8 replies
-
It's important to note that this behavior has a workaround (as stated in the linked issue). Adding an extra newline after the license comment will prevent the import sorter from moving it. Playground That being said, I think this would be nice to have because it lowers one more barrier for adoption. |
Beta Was this translation helpful? Give feedback.
-
How can Biome understand a license banner from a normal comment? I'm out of ideas, looking for some |
Beta Was this translation helpful? Give feedback.
-
Here, I implemented the functionality for you in Python and ChatGPT 4o translated it into Rust: EDIT: Fixed a minor bug which prevented a newline from being placed between import groups. |
Beta Was this translation helpful? Give feedback.
-
Currently, Biome does not differentiate between regular comments and license headers in the imports section at the top of source code files. This produces the effect, whereby some imports might be moved at the top of the file on line 1, above the license header, when imports are sorted.
Using license headers at the top of source code files is a standard practice in public-domain and proprietary software, where companies and organizations need to clearly outline the legal permissions that govern the given source code. This is standard use case and Biome does not currently respect this.
The proposal is to modify the imports sorting algorithm, such that it will always treat a multiline comment at the top of a source code file as a license header and will not move any import statements above it.
This is a call to all readers to please voice your opinion on this subject, whether you agree or disagree with this proposal, because the Biome devs need community support for implementing standard use cases into the Biome software.
This is the invalid result when
biome check --write
is executed on a file whichrequires import sorting and contains a license header:
This is the expected result:
This discussion is motivated from the following issue: #4210 (comment)
Beta Was this translation helpful? Give feedback.
All reactions