feat(css_formatter): format functions and binary expressions #1347
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
#1285. Functions and binary expressions can now be formatted, and they should roughly match Prettier's output (the generated IR is very similar, at least, but I haven't stress-tested it yet). Hex colors are also formatted now, and will be printed in lowercase always, thanks to a new utility struct,
FormatTokenAsLowercase
. As mentioned in #1346, I think there should be a more generic way to lowercase keywords, but this struct is useful in the meantime for handling identifiers that need to only sometimes be converted.Test Plan
Added tests mostly based off of Prettier's tests for functions. It seems like whitespace-separate parameters for functions aren't parsed quite yet, which leads to verbatim formatting for that in the one spec test for colors. All of the other formatting that changed previously for
var
and the like seems to be fixed now, as well.