forked from biomejs/biome
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(css_formatter): automatically downcase all keywords and regular …
…identifiers (biomejs#1354)
- Loading branch information
1 parent
c212dd6
commit b99e785
Showing
11 changed files
with
188 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -182,9 +182,9 @@ Line width: 80 | |
margin: 20px; | ||
} | ||
|
||
@page :FIRST { | ||
@page :first { | ||
} | ||
@page :LEFT { | ||
@page :left { | ||
} | ||
``` | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
/* | ||
* All values in CSS are case-insensitive except for Custom and Dashed | ||
* identifiers. Everything else can and will be re-written in lowercase. | ||
*/ | ||
|
||
DIV { COLOR: BLUE; } | ||
|
||
DIV.classNames#AND_Ids.ArePreserved {} | ||
|
||
[attr=IdentifierValuesPreserveWhenStringified] {} | ||
|
||
@MEDiA NoT SCReEN AND ( CoLOR ), PRINT AND (COLOR) { } | ||
|
||
DIV { | ||
--Preserved-Casing: BLUE; | ||
ColOR: VAR(--Preserved-Casing); | ||
} | ||
|
||
@font-PALETTE-values --AnyCASInG-works { } | ||
|
||
/* | ||
* The only exception (at least that I've found so far in the spec), is @page | ||
* using a _regular_ identifier for the page name, but where that identifier is | ||
* considered case-sensitive. Biome uses a CssCustomIdentifier here instead to | ||
* automatically preserve casing rather than creating a special exception. | ||
*/ | ||
@PAGE ThisIsPreserved:FIRST { | ||
|
||
} |
91 changes: 91 additions & 0 deletions
91
crates/biome_css_formatter/tests/specs/css/casing.css.snap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
--- | ||
source: crates/biome_formatter_test/src/snapshot_builder.rs | ||
info: css/casing.css | ||
--- | ||
|
||
# Input | ||
|
||
```css | ||
/* | ||
* All values in CSS are case-insensitive except for Custom and Dashed | ||
* identifiers. Everything else can and will be re-written in lowercase. | ||
*/ | ||
|
||
DIV { COLOR: BLUE; } | ||
|
||
DIV.classNames#AND_Ids.ArePreserved {} | ||
|
||
[attr=IdentifierValuesPreserveWhenStringified] {} | ||
|
||
@MEDiA NoT SCReEN AND ( CoLOR ), PRINT AND (COLOR) { } | ||
|
||
DIV { | ||
--Preserved-Casing: BLUE; | ||
ColOR: VAR(--Preserved-Casing); | ||
} | ||
|
||
@font-PALETTE-values --AnyCASInG-works { } | ||
|
||
/* | ||
* The only exception (at least that I've found so far in the spec), is @page | ||
* using a _regular_ identifier for the page name, but where that identifier is | ||
* considered case-sensitive. Biome uses a CssCustomIdentifier here instead to | ||
* automatically preserve casing rather than creating a special exception. | ||
*/ | ||
@PAGE ThisIsPreserved:FIRST { | ||
|
||
} | ||
``` | ||
|
||
|
||
============================= | ||
|
||
# Outputs | ||
|
||
## Output 1 | ||
|
||
----- | ||
Indent style: Tab | ||
Indent width: 2 | ||
Line ending: LF | ||
Line width: 80 | ||
----- | ||
|
||
```css | ||
/* | ||
* All values in CSS are case-insensitive except for Custom and Dashed | ||
* identifiers. Everything else can and will be re-written in lowercase. | ||
*/ | ||
|
||
div { | ||
color: blue; | ||
} | ||
|
||
div.classNames#AND_Ids.ArePreserved { | ||
} | ||
|
||
[attr="IdentifierValuesPreserveWhenStringified"] { | ||
} | ||
|
||
@media not screen and (color), print and (color) { | ||
} | ||
|
||
div { | ||
--preserved-casing: blue; | ||
color: var(--Preserved-Casing); | ||
} | ||
|
||
@font-palette-values --AnyCASInG-works { | ||
} | ||
|
||
/* | ||
* The only exception (at least that I've found so far in the spec), is @page | ||
* using a _regular_ identifier for the page name, but where that identifier is | ||
* considered case-sensitive. Biome uses a CssCustomIdentifier here instead to | ||
* automatically preserve casing rather than creating a special exception. | ||
*/ | ||
@page ThisIsPreserved:first { | ||
} | ||
``` | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters