feat(css_formatter): automatically downcase all keywords and regular identifiers #1354
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
Dependent on #1353. This PR starts automatically writing all keywords and regular identifiers in lowercase. By definition in the spec, this should be a safe transformation, but only because we now distinguish between regular and custom/dashed identifiers (the latter are case sensitive). The one apparent exception that I've found,
@page
rule names, is also parsed using aCssCustomIdentifier
, ensuring that it preserves casing, even though the spec uses a regular<ident>
and just states "this one's case sensitive".This behavior is similar to what Prettier does, but actually a lot more consistent. Prettier does not downcase type selectors, attribute selectors, value definitions, and other things, even though they are explicitly defined as case-insensitive. Biome's behavior after this PR will be an intentional deviation from Prettier, and once we get to Prettier compatibility testing, I'll be sure to add a note about it there. For example:
Biome's result ensures a much more consistent output while still preserving all of the actually-sensitive values: the class name and attribute matcher value in this example.
Test Plan
Added a new test specifically for testing the different casing situations, and all of the other spec tests have updated with the downcasing now.