feat(css_formatter): Basic css formatting of rules, selectors, and declarations #1256
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
Most of this is just the basic structuring of formats for css files. Rule lists and declaration lists get formatted and preserve their empty lines and all, selector lists get formatted onto individual lines and indented appropriately, complex and compound selectors get spaced properly.
This doesn't include anything for at-rules or custom properties or anything beyond just the plain CSS syntax (basically css 2-ish). It also doesn't include anything for pseudos, nor anything for formatting the actual values in any declarations. That will be started in the next PR.
Once this merges, I plan to create an umbrella issue covering all of the remaining nodes that need formatting support. There will also need to be support for placing comments as well.
Test Plan
I tried adding tests for each type of node that gained support, but there are also intermediate nodes that essentially get covered by other tests, so there aren't any dedicated to those.
Trying to read through the Prettier test suite, the amount of pure css tests is surprisingly low. A lot of them rely on PostCSS syntax and features, making it hard to port them over and be meaningful. More tests should be added in the future as the parser gains additional support, but for now these feel like they're working well and covering everything.