-
-
Notifications
You must be signed in to change notification settings - Fork 794
fix(css): updating formatting of non-lowercase CSS dimension units #8175
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
fix(css): updating formatting of non-lowercase CSS dimension units #8175
Conversation
🦋 Changeset detectedLatest commit: bc9dc9e The changes in this PR will be included in the next version bump. This PR includes changesets to release 13 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
|
Caution Review failedThe pull request is closed. WalkthroughThis pull request introduces Possibly related PRs
Suggested reviewers
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
📜 Recent review detailsConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro 📒 Files selected for processing (1)
Tip 📝 Customizable high-level summaries are now available in beta!You can now customize how CodeRabbit generates the high-level summary in your pull requests — including its content, structure, tone, and formatting.
Example instruction:
Note: This feature is currently in beta for Pro-tier users, and pricing will be announced later. Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (1)
crates/biome_css_formatter/tests/specs/css/units.css.snapis excluded by!**/*.snapand included by**
📒 Files selected for processing (4)
.changeset/wise-dots-rush.md(1 hunks)crates/biome_css_formatter/src/css/value/regular_dimension.rs(2 hunks)crates/biome_css_formatter/src/css/value/unknown_dimension.rs(2 hunks)crates/biome_css_formatter/src/utils/string_utils.rs(1 hunks)
🧰 Additional context used
🧬 Code graph analysis (3)
crates/biome_css_formatter/src/css/value/unknown_dimension.rs (1)
crates/biome_css_formatter/src/utils/string_utils.rs (2)
from(24-26)from(305-307)
crates/biome_css_formatter/src/utils/string_utils.rs (4)
crates/biome_html_formatter/src/utils/formatters.rs (1)
fmt(22-34)crates/biome_css_formatter/src/lib.rs (8)
fmt(192-201)fmt(245-247)fmt(310-326)format(45-45)format(58-60)format(75-80)format(95-97)format(342-344)crates/biome_formatter/src/builders.rs (2)
token(251-259)text(279-283)crates/biome_css_formatter/src/trivia.rs (1)
format_replaced(30-38)
crates/biome_css_formatter/src/css/value/regular_dimension.rs (1)
crates/biome_css_formatter/src/utils/string_utils.rs (2)
from(24-26)from(305-307)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (11)
- GitHub Check: Documentation
- GitHub Check: Test (depot-windows-2022-16)
- GitHub Check: Test (depot-ubuntu-24.04-arm-16)
- GitHub Check: Check Dependencies
- GitHub Check: Lint project (depot-windows-2022)
- GitHub Check: Lint project (depot-ubuntu-24.04-arm-16)
- GitHub Check: Bench (biome_css_formatter)
- GitHub Check: Bench (biome_css_parser)
- GitHub Check: Bench (biome_css_analyze)
- GitHub Check: autofix
- GitHub Check: Test Node.js API
🔇 Additional comments (5)
crates/biome_css_formatter/src/css/value/unknown_dimension.rs (1)
1-4: LGTM!The import and usage correctly apply the new
FormatDimensionUnitformatter to the unit token.Also applies to: 21-21
.changeset/wise-dots-rush.md (1)
1-25: LGTM!Clear documentation with helpful before/after examples.
crates/biome_css_formatter/src/css/value/regular_dimension.rs (1)
1-1: LGTM!Correctly applies the new
FormatDimensionUnitformatter.Also applies to: 18-18
crates/biome_css_formatter/src/utils/string_utils.rs (2)
300-308: Structure looks good.The struct definition and
Fromimplementation follow the established pattern fromFormatTokenAsLowercase.
310-338: Test coverage gap confirmed—add lowercase unit test cases.The current snapshot tests only cover uppercase inputs (5HZ, 5KHZ, 5Q). There are no test cases for already-lowercase units (5hz, 5khz, 5q), which means the match logic in the formatter code is never exercised by the tests. Add test cases for lowercase inputs to
crates/biome_css_formatter/tests/specs/css/units.cssto ensure complete coverage of the casing conversion logic.
CodSpeed Performance ReportMerging #8175 will not alter performanceComparing Summary
Footnotes
|
…iomejs#8175) Co-authored-by: Emanuele Stoppa <[email protected]>
…iomejs#8175) Co-authored-by: Emanuele Stoppa <[email protected]>
Summary
I noticed while working on issue #6183 that the some CSS dimension units are being formatted inconsistently than how they are handled by Prettier. Most units are formatted to lowercase but a few are formatted with some uppercase letters, both in most documentation examples and in Prettier. Specifically
Q,hZandkHz. This PR adds a newFormatDimensionUnitutil based on theFormatTokenAsLowercasethat maps the special units to the correct formatting. My understanding is the the formatter is aimed to maintain parity with Prettier so I figured I'd open a quick PR with this change.Let me know if a patch makes sense here. This change could change user's existing formatted code so wasn't sure if patch made the most sense or not
Test Plan
crates/biome_css_formatter/tests/specs/css/units.css.snapsnapshot test updated to reflect the new formattingDocs
n/a
AI Usage Disclosure
Really didn't use much AI at all. All code was hand written.