fix(css_formatter): improve comment handling in generic CSS properties#10439
Conversation
🦋 Changeset detectedLatest commit: 20dab33 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 |
✅ Organic activityNo automation signals detected in the analyzed events. This is an automated analysis by AgentScan |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
✅ Files skipped from review due to trivial changes (1)
WalkthroughThis PR preserves comments that sit at the colon/value boundary in CSS/SCSS declarations. It updates comment classification in comments.rs to detect comments between a property's colon and its value, refactors generic-property formatting to centralise colon/value comment handling with per-comment spacing/break rules, and adds CSS/SCSS tests plus a changeset documenting the patch. Possibly related PRs
Suggested labels
Suggested reviewers
🚥 Pre-merge checks | ✅ 4✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Warning Review ran into problems🔥 ProblemsStopped waiting for pipeline failures after 30000ms. One of your pipelines takes longer than our 30000ms fetch window to run, so review may not consider pipeline-failure results for inline comments if any failures occurred after the fetch window. Increase the timeout if you want to wait longer or run a 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 |
Merging this PR will not alter performance
Comparing Footnotes
|
This PR contains the following updates: | Package | Type | Update | Change | |---|---|---|---| | [@biomejs/biome](https://biomejs.dev) ([source](https://github.com/biomejs/biome/tree/HEAD/packages/@biomejs/biome)) | imports | patch | [`2.4.15` -> `2.4.16`](https://renovatebot.com/diffs/npm/@biomejs%2fbiome/2.4.15/2.4.16) | --- ### Release Notes <details> <summary>biomejs/biome (@​biomejs/biome)</summary> ### [`v2.4.16`](https://github.com/biomejs/biome/blob/HEAD/packages/@​biomejs/biome/CHANGELOG.md#2416) [Compare Source](https://github.com/biomejs/biome/compare/@biomejs/biome@2.4.15...@biomejs/biome@2.4.16) ##### Patch Changes - [#​10329](biomejs/biome#10329) [`ef764d5`](biomejs/biome@ef764d5) Thanks [@​Conaclos](https://github.com/Conaclos)! - Fixed an issue where diagnostics showed an incorrect location in Astro files. - [#​10363](biomejs/biome#10363) [`50aa415`](biomejs/biome@50aa415) Thanks [@​dyc3](https://github.com/dyc3)! - Fixed HTML formatting for a case where comments could cause the formatter to split up a closing tag, which would cause the resulting HTML to be syntactically invalid. Input: ```html <span ><!-- 1 --><span>a</span ><!-- 2 --><span>b</span ><!-- 3 --></span> ``` Output: ```diff <span ><!-- 1 - --> <span>a</span<!-- 2 - --> ><span>b</span><!-- 3 + --><span>a</span><!-- 2 + --><span>b</span><!-- 3 --></span > ``` - [#​10465](biomejs/biome#10465) [`0c718da`](biomejs/biome@0c718da) Thanks [@​dfedoryshchev](https://github.com/dfedoryshchev)! - Fixed diagnostics emitted by the `noUntrustedLicenses` rule. - [#​10358](biomejs/biome#10358) [`05c2617`](biomejs/biome@05c2617) Thanks [@​dyc3](https://github.com/dyc3)! - Fixed [#​10356](biomejs/biome#10356): `biome rage --linter` now displays rules enabled through linter domains in the enabled rules list. - [#​10300](biomejs/biome#10300) [`950247c`](biomejs/biome@950247c) Thanks [@​dyc3](https://github.com/dyc3)! - Fixed [#​10265](biomejs/biome#10265): Svelte function bindings such as `bind:value={get, set}` are now parsed more precisely, so [`noCommaOperator`](https://biomejs.dev/linter/rules/no-comma-operator/) won't emit false positives for that syntax anymore. - [#​9786](biomejs/biome#9786) [`e71f584`](biomejs/biome@e71f584) Thanks [@​MeGaNeKoS](https://github.com/MeGaNeKoS)! - Fixed [#​8480](biomejs/biome#8480): [`useDestructuring`](https://biomejs.dev/linter/rules/use-destructuring/) now provides `variableDeclarator` and `assignmentExpression` options to control which contexts enforce destructuring, matching ESLint's `prefer-destructuring` configuration. Both default to `{array: true, object: true}`. The diagnostic for object destructuring in assignment expressions now instructs users to wrap the assignment in parentheses. - [#​10425](biomejs/biome#10425) [`1948b72`](biomejs/biome@1948b72) Thanks [@​sjh9714](https://github.com/sjh9714)! - Fixed [#​10244](biomejs/biome#10244): The `useOptionalChain` rule now detects negated guard inequality chains like `!foo || foo.bar !== "x"`. - [#​10442](biomejs/biome#10442) [`001f94f`](biomejs/biome@001f94f) Thanks [@​ematipico](https://github.com/ematipico)! - Fixed [#​10411](biomejs/biome#10411): [`noMisusedPromises`](https://biomejs.dev/linter/rules/no-misused-promises/) no longer causes a stack overflow when a nested function returns an object with shorthand properties that shadow destructured variables from an outer scope. - [#​10318](biomejs/biome#10318) [`9b1577f`](biomejs/biome@9b1577f) Thanks [@​dyc3](https://github.com/dyc3)! - Added support for `formatter.trailingCommas` in overrides. This option was previously available in the top-level formatter configuration but missing from formatter overrides. - [#​10319](biomejs/biome#10319) [`2e37709`](biomejs/biome@2e37709) Thanks [@​dyc3](https://github.com/dyc3)! - Fixed Vue and Svelte formatting for standalone interpolations in inline elements. Biome now preserves existing newlines in cases like: ```diff - <span> {{ value }} </span> + <span> + {{ value }} + </span> ``` - [#​10365](biomejs/biome#10365) [`0a58eb0`](biomejs/biome@0a58eb0) Thanks [@​Netail](https://github.com/Netail)! - Fixed [#​10361](biomejs/biome#10361): [`noUnusedFunctionParameters`](https://biomejs.dev/linter/rules/no-unused-function-parameters/) now mentions the parameter name in the diagnostic. - [#​10439](biomejs/biome#10439) [`df6b867`](biomejs/biome@df6b867) Thanks [@​denbezrukov](https://github.com/denbezrukov)! - Fixed CSS and SCSS formatting for comments around declaration colons so comments between property names, colons, and values stay at the same boundary as Prettier. ```diff .selector { - color: /* red, */ - blue; + color: /* red, */ blue; } ``` - [#​10344](biomejs/biome#10344) [`b30208c`](biomejs/biome@b30208c) Thanks [@​siketyan](https://github.com/siketyan)! - Fixed [`#10123`](biomejs/biome#10123): Corrected the [`noReactNativeDeepImports`](https://biomejs.dev/linter/rules/no-react-native-deep-imports/) source rule to point to the proper upstream rule, so users can migrate from the original rule correctly. - [#​10328](biomejs/biome#10328) [`b59133f`](biomejs/biome@b59133f) Thanks [@​dyc3](https://github.com/dyc3)! - Fixed [#​10309](biomejs/biome#10309): Biome no longer adds newlines to Astro frontmatter when linter or assist `--write` mode is enabled. </details> --- ### Configuration 📅 **Schedule**: (UTC) - Branch creation - At any time (no schedule defined) - Automerge - At any time (no schedule defined) 🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied. ♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this PR and you won't be reminded about this update again. --- - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box --- This PR has been generated by [Mend Renovate](https://github.com/renovatebot/renovate). <!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiI0My4xOTUuMiIsInVwZGF0ZWRJblZlciI6IjQzLjE5NS4yIiwidGFyZ2V0QnJhbmNoIjoibWFpbiIsImxhYmVscyI6W119--> Reviewed-on: https://git.oirnoir.dev/OIRNOIR/YouTube-Helper-Client/pulls/5
This PR contains the following updates: | Package | Type | Update | Change | |---|---|---|---| | [@biomejs/biome](https://biomejs.dev) ([source](https://github.com/biomejs/biome/tree/HEAD/packages/@biomejs/biome)) | imports | patch | [`2.4.15` -> `2.4.16`](https://renovatebot.com/diffs/npm/@biomejs%2fbiome/2.4.15/2.4.16) | --- ### Release Notes <details> <summary>biomejs/biome (@​biomejs/biome)</summary> ### [`v2.4.16`](https://github.com/biomejs/biome/blob/HEAD/packages/@​biomejs/biome/CHANGELOG.md#2416) [Compare Source](https://github.com/biomejs/biome/compare/@biomejs/biome@2.4.15...@biomejs/biome@2.4.16) ##### Patch Changes - [#​10329](biomejs/biome#10329) [`ef764d5`](biomejs/biome@ef764d5) Thanks [@​Conaclos](https://github.com/Conaclos)! - Fixed an issue where diagnostics showed an incorrect location in Astro files. - [#​10363](biomejs/biome#10363) [`50aa415`](biomejs/biome@50aa415) Thanks [@​dyc3](https://github.com/dyc3)! - Fixed HTML formatting for a case where comments could cause the formatter to split up a closing tag, which would cause the resulting HTML to be syntactically invalid. Input: ```html <span ><!-- 1 --><span>a</span ><!-- 2 --><span>b</span ><!-- 3 --></span> ``` Output: ```diff <span ><!-- 1 - --> <span>a</span<!-- 2 - --> ><span>b</span><!-- 3 + --><span>a</span><!-- 2 + --><span>b</span><!-- 3 --></span > ``` - [#​10465](biomejs/biome#10465) [`0c718da`](biomejs/biome@0c718da) Thanks [@​dfedoryshchev](https://github.com/dfedoryshchev)! - Fixed diagnostics emitted by the `noUntrustedLicenses` rule. - [#​10358](biomejs/biome#10358) [`05c2617`](biomejs/biome@05c2617) Thanks [@​dyc3](https://github.com/dyc3)! - Fixed [#​10356](biomejs/biome#10356): `biome rage --linter` now displays rules enabled through linter domains in the enabled rules list. - [#​10300](biomejs/biome#10300) [`950247c`](biomejs/biome@950247c) Thanks [@​dyc3](https://github.com/dyc3)! - Fixed [#​10265](biomejs/biome#10265): Svelte function bindings such as `bind:value={get, set}` are now parsed more precisely, so [`noCommaOperator`](https://biomejs.dev/linter/rules/no-comma-operator/) won't emit false positives for that syntax anymore. - [#​9786](biomejs/biome#9786) [`e71f584`](biomejs/biome@e71f584) Thanks [@​MeGaNeKoS](https://github.com/MeGaNeKoS)! - Fixed [#​8480](biomejs/biome#8480): [`useDestructuring`](https://biomejs.dev/linter/rules/use-destructuring/) now provides `variableDeclarator` and `assignmentExpression` options to control which contexts enforce destructuring, matching ESLint's `prefer-destructuring` configuration. Both default to `{array: true, object: true}`. The diagnostic for object destructuring in assignment expressions now instructs users to wrap the assignment in parentheses. - [#​10425](biomejs/biome#10425) [`1948b72`](biomejs/biome@1948b72) Thanks [@​sjh9714](https://github.com/sjh9714)! - Fixed [#​10244](biomejs/biome#10244): The `useOptionalChain` rule now detects negated guard inequality chains like `!foo || foo.bar !== "x"`. - [#​10442](biomejs/biome#10442) [`001f94f`](biomejs/biome@001f94f) Thanks [@​ematipico](https://github.com/ematipico)! - Fixed [#​10411](biomejs/biome#10411): [`noMisusedPromises`](https://biomejs.dev/linter/rules/no-misused-promises/) no longer causes a stack overflow when a nested function returns an object with shorthand properties that shadow destructured variables from an outer scope. - [#​10318](biomejs/biome#10318) [`9b1577f`](biomejs/biome@9b1577f) Thanks [@​dyc3](https://github.com/dyc3)! - Added support for `formatter.trailingCommas` in overrides. This option was previously available in the top-level formatter configuration but missing from formatter overrides. - [#​10319](biomejs/biome#10319) [`2e37709`](biomejs/biome@2e37709) Thanks [@​dyc3](https://github.com/dyc3)! - Fixed Vue and Svelte formatting for standalone interpolations in inline elements. Biome now preserves existing newlines in cases like: ```diff - <span> {{ value }} </span> + <span> + {{ value }} + </span> ``` - [#​10365](biomejs/biome#10365) [`0a58eb0`](biomejs/biome@0a58eb0) Thanks [@​Netail](https://github.com/Netail)! - Fixed [#​10361](biomejs/biome#10361): [`noUnusedFunctionParameters`](https://biomejs.dev/linter/rules/no-unused-function-parameters/) now mentions the parameter name in the diagnostic. - [#​10439](biomejs/biome#10439) [`df6b867`](biomejs/biome@df6b867) Thanks [@​denbezrukov](https://github.com/denbezrukov)! - Fixed CSS and SCSS formatting for comments around declaration colons so comments between property names, colons, and values stay at the same boundary as Prettier. ```diff .selector { - color: /* red, */ - blue; + color: /* red, */ blue; } ``` - [#​10344](biomejs/biome#10344) [`b30208c`](biomejs/biome@b30208c) Thanks [@​siketyan](https://github.com/siketyan)! - Fixed [`#10123`](biomejs/biome#10123): Corrected the [`noReactNativeDeepImports`](https://biomejs.dev/linter/rules/no-react-native-deep-imports/) source rule to point to the proper upstream rule, so users can migrate from the original rule correctly. - [#​10328](biomejs/biome#10328) [`b59133f`](biomejs/biome@b59133f) Thanks [@​dyc3](https://github.com/dyc3)! - Fixed [#​10309](biomejs/biome#10309): Biome no longer adds newlines to Astro frontmatter when linter or assist `--write` mode is enabled. </details> --- ### Configuration 📅 **Schedule**: (UTC) - Branch creation - At any time (no schedule defined) - Automerge - At any time (no schedule defined) 🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied. ♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this PR and you won't be reminded about this update again. --- - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box --- This PR has been generated by [Mend Renovate](https://github.com/renovatebot/renovate). <!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiI0My4xOTUuMiIsInVwZGF0ZWRJblZlciI6IjQzLjE5NS4yIiwidGFyZ2V0QnJhbmNoIjoibWFpbiIsImxhYmVscyI6W119--> Reviewed-on: https://git.oirnoir.dev/OIRNOIR/YouTube-Helper-Server/pulls/13
Summary
Improves CSS and SCSS formatting for comments around declaration colons so comments between property names, colons, and values stay attached to the same boundary as Prettier.
Previously, Biome could format this as:
Now it preserves the colon/value boundary:
Test Plan