Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(css_formatter): CSS formatter converts variable declarations and …
Browse files Browse the repository at this point in the history
…function calls to lowercase #3068
denbezrukov committed Jun 8, 2024
1 parent 8fe1d5f commit 35f93bb
Showing 10 changed files with 60 additions and 75 deletions.
Original file line number Diff line number Diff line change
@@ -9,7 +9,7 @@ impl FormatRule<CssLayerNameList> for FormatCssLayerNameList {
type Context = CssFormatContext;
fn fmt(&self, node: &CssLayerNameList, f: &mut CssFormatter) -> FormatResult<()> {
f.join()
.entries(node.format_separated_with_options1(
.entries(node.format_separated_with_options(
".",
FormatCssIdentifierOptions::default().prevent_lowercase(true),
))
2 changes: 1 addition & 1 deletion crates/biome_css_formatter/src/separated.rs
Original file line number Diff line number Diff line change
@@ -110,7 +110,7 @@ pub(crate) trait FormatAstSeparatedListWithOptionsExtension<O>:
/// calling the `separator_factory` function. The last trailing separator
/// will not be printed by default. Use `with_trailing_separator` to add it
/// in where necessary.
fn format_separated_with_options1(
fn format_separated_with_options(
&self,
separator: &'static str,
options: O,
Original file line number Diff line number Diff line change
@@ -2,7 +2,6 @@
source: crates/biome_css_parser/tests/spec_test.rs
expression: snapshot
---

## Input

```css
@@ -83,7 +82,7 @@ CssRoot {
CssDeclarationWithSemicolon {
declaration: CssDeclaration {
property: CssGenericProperty {
name: CssIdentifier {
name: CssDashedIdentifier {
value_token: IDENT@43..56 "--custom" [Newline("\n"), Whitespace(" ")] [],
},
colon_token: COLON@56..58 ":" [] [Whitespace(" ")],
@@ -162,7 +161,7 @@ CssRoot {
2: CSS_DECLARATION_WITH_SEMICOLON@43..64
0: CSS_DECLARATION@43..63
0: CSS_GENERIC_PROPERTY@43..63
0: CSS_IDENTIFIER@43..56
0: CSS_DASHED_IDENTIFIER@43..56
0: IDENT@43..56 "--custom" [Newline("\n"), Whitespace(" ")] []
1: COLON@56..58 ":" [] [Whitespace(" ")]
2: CSS_GENERIC_COMPONENT_VALUE_LIST@58..63
@@ -239,5 +238,3 @@ property_generic_error.css:4:20 parse ━━━━━━━━━━━━━━
5 │ }
```
Original file line number Diff line number Diff line change
@@ -141,7 +141,7 @@ CssRoot {
l_paren_token: L_PAREN@136..137 "(" [] [],
query: CssDeclaration {
property: CssGenericProperty {
name: CssIdentifier {
name: CssDashedIdentifier {
value_token: IDENT@137..149 "--responsive" [] [],
},
colon_token: COLON@149..151 ":" [] [Whitespace(" ")],
@@ -408,7 +408,7 @@ CssRoot {
l_paren_token: L_PAREN@486..487 "(" [] [],
query: CssDeclaration {
property: CssGenericProperty {
name: CssIdentifier {
name: CssDashedIdentifier {
value_token: IDENT@487..499 "--responsive" [] [],
},
colon_token: COLON@499..501 ":" [] [Whitespace(" ")],
@@ -724,7 +724,7 @@ CssRoot {
1: L_PAREN@136..137 "(" [] []
2: CSS_DECLARATION@137..155
0: CSS_GENERIC_PROPERTY@137..155
0: CSS_IDENTIFIER@137..149
0: CSS_DASHED_IDENTIFIER@137..149
0: IDENT@137..149 "--responsive" [] []
1: COLON@149..151 ":" [] [Whitespace(" ")]
2: CSS_GENERIC_COMPONENT_VALUE_LIST@151..155
@@ -913,7 +913,7 @@ CssRoot {
1: L_PAREN@486..487 "(" [] []
2: CSS_DECLARATION@487..505
0: CSS_GENERIC_PROPERTY@487..505
0: CSS_IDENTIFIER@487..499
0: CSS_DASHED_IDENTIFIER@487..499
0: IDENT@487..499 "--responsive" [] []
1: COLON@499..501 ":" [] [Whitespace(" ")]
2: CSS_GENERIC_COMPONENT_VALUE_LIST@501..505

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -2301,7 +2301,7 @@ CssRoot {
l_paren_token: L_PAREN@2191..2192 "(" [] [],
declaration: CssDeclaration {
property: CssGenericProperty {
name: CssIdentifier {
name: CssDashedIdentifier {
value_token: IDENT@2192..2197 "--foo" [] [],
},
colon_token: COLON@2197..2199 ":" [] [Whitespace(" ")],
@@ -3215,7 +3215,7 @@ CssRoot {
l_paren_token: L_PAREN@2939..2943 "(" [] [Whitespace(" ")],
declaration: CssDeclaration {
property: CssGenericProperty {
name: CssIdentifier {
name: CssDashedIdentifier {
value_token: IDENT@2943..2948 "--var" [] [],
},
colon_token: COLON@2948..2952 ":" [] [Whitespace(" ")],
@@ -4830,7 +4830,7 @@ CssRoot {
0: L_PAREN@2191..2192 "(" [] []
1: CSS_DECLARATION@2192..2204
0: CSS_GENERIC_PROPERTY@2192..2204
0: CSS_IDENTIFIER@2192..2197
0: CSS_DASHED_IDENTIFIER@2192..2197
0: IDENT@2192..2197 "--foo" [] []
1: COLON@2197..2199 ":" [] [Whitespace(" ")]
2: CSS_GENERIC_COMPONENT_VALUE_LIST@2199..2204
@@ -5439,7 +5439,7 @@ CssRoot {
0: L_PAREN@2939..2943 "(" [] [Whitespace(" ")]
1: CSS_DECLARATION@2943..2961
0: CSS_GENERIC_PROPERTY@2943..2961
0: CSS_IDENTIFIER@2943..2948
0: CSS_DASHED_IDENTIFIER@2943..2948
0: IDENT@2943..2948 "--var" [] []
1: COLON@2948..2952 ":" [] [Whitespace(" ")]
2: CSS_GENERIC_COMPONENT_VALUE_LIST@2952..2961
Original file line number Diff line number Diff line change
@@ -2,7 +2,6 @@
source: crates/biome_css_parser/tests/spec_test.rs
expression: snapshot
---

## Input

```css
@@ -575,7 +574,7 @@ CssRoot {
CssDeclarationWithSemicolon {
declaration: CssDeclaration {
property: CssGenericProperty {
name: CssIdentifier {
name: CssDashedIdentifier {
value_token: IDENT@337..364 "--bs-btn-focus-shadow-rgb" [Newline("\n"), Whitespace("\t")] [],
},
colon_token: COLON@364..366 ":" [] [Whitespace(" ")],
@@ -1000,7 +999,7 @@ CssRoot {
0: CSS_DECLARATION_WITH_SEMICOLON@337..377
0: CSS_DECLARATION@337..376
0: CSS_GENERIC_PROPERTY@337..376
0: CSS_IDENTIFIER@337..364
0: CSS_DASHED_IDENTIFIER@337..364
0: IDENT@337..364 "--bs-btn-focus-shadow-rgb" [Newline("\n"), Whitespace("\t")] []
1: COLON@364..366 ":" [] [Whitespace(" ")]
2: CSS_GENERIC_COMPONENT_VALUE_LIST@366..376
@@ -1053,5 +1052,3 @@ CssRoot {
2: EOF@455..456 "" [Newline("\n")] []
```
Original file line number Diff line number Diff line change
@@ -2,7 +2,6 @@
source: crates/biome_css_parser/tests/spec_test.rs
expression: snapshot
---

## Input

```css
@@ -250,7 +249,7 @@ CssRoot {
CssDeclarationWithSemicolon {
declaration: CssDeclaration {
property: CssGenericProperty {
name: CssIdentifier {
name: CssDashedIdentifier {
value_token: [email protected] "--width" [Newline("\n"), Whitespace(" ")] [],
},
colon_token: [email protected] ":" [] [Whitespace(" ")],
@@ -5062,7 +5061,7 @@ CssRoot {
0: [email protected]
0: [email protected]
0: [email protected]
0: CSS_IDENTIFIER@49..61
0: CSS_DASHED_IDENTIFIER@49..61
0: [email protected] "--width" [Newline("\n"), Whitespace(" ")] []
1: [email protected] ":" [] [Whitespace(" ")]
2: [email protected]
@@ -8040,5 +8039,3 @@ CssRoot {
2: [email protected] "" [] []

```


Original file line number Diff line number Diff line change
@@ -2,7 +2,6 @@
source: crates/biome_css_parser/tests/spec_test.rs
expression: snapshot
---

## Input

```css
@@ -207,7 +206,7 @@ CssRoot {
CssDeclarationWithSemicolon {
declaration: CssDeclaration {
property: CssGenericProperty {
name: CssIdentifier {
name: CssDashedIdentifier {
value_token: IDENT@298..363 "--custom-property" [Newline("\n"), Newline("\n"), Whitespace(" "), Comments("/* Custom property, a ..."), Newline("\n"), Whitespace(" ")] [],
},
colon_token: COLON@363..365 ":" [] [Whitespace(" ")],
@@ -227,7 +226,7 @@ CssRoot {
CssDeclarationWithSemicolon {
declaration: CssDeclaration {
property: CssGenericProperty {
name: CssIdentifier {
name: CssDashedIdentifier {
value_token: IDENT@373..395 "--custom-property" [Newline("\n"), Whitespace(" ")] [],
},
colon_token: COLON@395..397 ":" [] [Whitespace(" ")],
@@ -244,7 +243,7 @@ CssRoot {
CssDeclarationWithSemicolon {
declaration: CssDeclaration {
property: CssGenericProperty {
name: CssIdentifier {
name: CssDashedIdentifier {
value_token: IDENT@407..429 "--custom-property" [Newline("\n"), Whitespace(" ")] [],
},
colon_token: COLON@429..431 ":" [] [Whitespace(" ")],
@@ -264,7 +263,7 @@ CssRoot {
CssDeclarationWithSemicolon {
declaration: CssDeclaration {
property: CssGenericProperty {
name: CssIdentifier {
name: CssDashedIdentifier {
value_token: IDENT@447..469 "--custom-property" [Newline("\n"), Whitespace(" ")] [],
},
colon_token: COLON@469..471 ":" [] [Whitespace(" ")],
@@ -287,7 +286,7 @@ CssRoot {
CssDeclarationWithSemicolon {
declaration: CssDeclaration {
property: CssGenericProperty {
name: CssIdentifier {
name: CssDashedIdentifier {
value_token: IDENT@489..511 "--custom-property" [Newline("\n"), Whitespace(" ")] [],
},
colon_token: COLON@511..513 ":" [] [Whitespace(" ")],
@@ -316,7 +315,7 @@ CssRoot {
CssDeclarationWithSemicolon {
declaration: CssDeclaration {
property: CssGenericProperty {
name: CssIdentifier {
name: CssDashedIdentifier {
value_token: IDENT@540..562 "--custom-property" [Newline("\n"), Whitespace(" ")] [],
},
colon_token: COLON@562..564 ":" [] [Whitespace(" ")],
@@ -622,7 +621,7 @@ CssRoot {
6: CSS_DECLARATION_WITH_SEMICOLON@298..373
0: CSS_DECLARATION@298..372
0: CSS_GENERIC_PROPERTY@298..372
0: CSS_IDENTIFIER@298..363
0: CSS_DASHED_IDENTIFIER@298..363
0: IDENT@298..363 "--custom-property" [Newline("\n"), Newline("\n"), Whitespace(" "), Comments("/* Custom property, a ..."), Newline("\n"), Whitespace(" ")] []
1: COLON@363..365 ":" [] [Whitespace(" ")]
2: CSS_GENERIC_COMPONENT_VALUE_LIST@365..372
@@ -635,7 +634,7 @@ CssRoot {
7: CSS_DECLARATION_WITH_SEMICOLON@373..407
0: CSS_DECLARATION@373..406
0: CSS_GENERIC_PROPERTY@373..406
0: CSS_IDENTIFIER@373..395
0: CSS_DASHED_IDENTIFIER@373..395
0: IDENT@373..395 "--custom-property" [Newline("\n"), Whitespace(" ")] []
1: COLON@395..397 ":" [] [Whitespace(" ")]
2: CSS_GENERIC_COMPONENT_VALUE_LIST@397..406
@@ -646,7 +645,7 @@ CssRoot {
8: CSS_DECLARATION_WITH_SEMICOLON@407..447
0: CSS_DECLARATION@407..446
0: CSS_GENERIC_PROPERTY@407..446
0: CSS_IDENTIFIER@407..429
0: CSS_DASHED_IDENTIFIER@407..429
0: IDENT@407..429 "--custom-property" [Newline("\n"), Whitespace(" ")] []
1: COLON@429..431 ":" [] [Whitespace(" ")]
2: CSS_GENERIC_COMPONENT_VALUE_LIST@431..446
@@ -659,7 +658,7 @@ CssRoot {
9: CSS_DECLARATION_WITH_SEMICOLON@447..489
0: CSS_DECLARATION@447..488
0: CSS_GENERIC_PROPERTY@447..488
0: CSS_IDENTIFIER@447..469
0: CSS_DASHED_IDENTIFIER@447..469
0: IDENT@447..469 "--custom-property" [Newline("\n"), Whitespace(" ")] []
1: COLON@469..471 ":" [] [Whitespace(" ")]
2: CSS_GENERIC_COMPONENT_VALUE_LIST@471..488
@@ -674,7 +673,7 @@ CssRoot {
10: CSS_DECLARATION_WITH_SEMICOLON@489..540
0: CSS_DECLARATION@489..539
0: CSS_GENERIC_PROPERTY@489..539
0: CSS_IDENTIFIER@489..511
0: CSS_DASHED_IDENTIFIER@489..511
0: IDENT@489..511 "--custom-property" [Newline("\n"), Whitespace(" ")] []
1: COLON@511..513 ":" [] [Whitespace(" ")]
2: CSS_GENERIC_COMPONENT_VALUE_LIST@513..539
@@ -693,7 +692,7 @@ CssRoot {
11: CSS_DECLARATION_WITH_SEMICOLON@540..597
0: CSS_DECLARATION@540..596
0: CSS_GENERIC_PROPERTY@540..596
0: CSS_IDENTIFIER@540..562
0: CSS_DASHED_IDENTIFIER@540..562
0: IDENT@540..562 "--custom-property" [Newline("\n"), Whitespace(" ")] []
1: COLON@562..564 ":" [] [Whitespace(" ")]
2: CSS_GENERIC_COMPONENT_VALUE_LIST@564..596
@@ -814,5 +813,3 @@ CssRoot {
2: EOF@827..827 "" [] []
```
Original file line number Diff line number Diff line change
@@ -2,7 +2,6 @@
source: crates/biome_css_parser/tests/spec_test.rs
expression: snapshot
---

## Input

```css
@@ -487,7 +486,7 @@ CssRoot {
CssDeclarationWithSemicolon {
declaration: CssDeclaration {
property: CssGenericProperty {
name: CssIdentifier {
name: CssDashedIdentifier {
value_token: IDENT@769..777 "--foo" [Newline("\n"), Newline("\n"), Whitespace("\t")] [],
},
colon_token: COLON@777..779 ":" [] [Whitespace(" ")],
@@ -1035,7 +1034,7 @@ CssRoot {
15: CSS_DECLARATION_WITH_SEMICOLON@769..816
0: CSS_DECLARATION@769..815
0: CSS_GENERIC_PROPERTY@769..815
0: CSS_IDENTIFIER@769..777
0: CSS_DASHED_IDENTIFIER@769..777
0: IDENT@769..777 "--foo" [Newline("\n"), Newline("\n"), Whitespace("\t")] []
1: COLON@777..779 ":" [] [Whitespace(" ")]
2: CSS_GENERIC_COMPONENT_VALUE_LIST@779..815
@@ -1201,5 +1200,3 @@ CssRoot {
2: EOF@1290..1291 "" [Newline("\n")] []
```

0 comments on commit 35f93bb

Please sign in to comment.