- dispatcher
- string_embedder
- tailwind_sorter
Group these 3 together as `SessionServices`, make them available to `FormatSession`, and pass them around.
Audited every formatter crate against the trailing-comment width discipline.
- same-line trailing line comments ride `line_suffix` and are excluded from the fits measurement
- while trailing block comments print inline and count
Corrected the prose that misstated it.
Fixes#24843
---
Tracing back to the root cause, this is also related to what had diverged because of Prettier's inconsistent behavior.
Since I cannot determine for sure how it should be output in more complex cases (like that issue) at this point, decided to revert to being Prettier-compatible.
Fixes#24000, #24057, and #24116.
Updating `oxc-css-parser` to 0.0.4 involved a massive amount of fixes, making it a major update.
However, this should allow us to catch cases that were previously missed (even potentially).
Fixes#23969, closes#23983.
Notably `oxc-css-parser@0.0.3` contains:
- partial `postcss-simple-vars` support
- fix glued css-in-js placeholder (`${C}:hover &`)
As `oxc_allocator` has also been added as a dependency in `oxc-css-parser`, this has caused a conflict with the latest local (workspace) instance, so a `patch.crates-io` section has also been added. Apparently, this is a technique also used in [Tokio](https://github.com/tokio-rs/tokio/blob/master/Cargo.toml#L18-L23).
Drop the manual custom-property reparse helper. Use the parser's `try_parsing_value_in_custom_property` option instead.
One new SCSS conformance failure (`scss/variables/apply-rule.scss`):
The new AST gives `SassNestingDeclaration` instead of token-soup, so the swallow case formats structurally instead of verbatim.
```scss
--p: { /* ... */ } /* <- nosemi */
--q: red;
```
CSS and Less are unaffected.
As we have forked the CSS parser, we can control how JS substitutions `${}` inside css-in-js are represented and how they interact.
We are no longer bound by Prettier’s conventions, allowing us to implement the code more efficiently.
- Before this PR: If `sortTailwindcss` option is enabled for CSS/LESS/SCSS, it was formatted by Prettier
- After this PR: `oxc_formatter_css` also handles `sortTailwindcss` as like `oxc_formatter` does
- Use `oxc_formatter_css` from Oxfmt to handle CSS/LESS/SCSS files
- css-in-js is also handled by `oxc_formatter_css`
- But it will fallback to Prettier if formatting failed
- No fallback for no-embedded path
- At the point of this PR, it will fallback to Prettier when tailwind is required to format
NOTE: Both fallback will be removed in later PR.
In that sense, as a result of this series of PRs, Oxfmt's CSS support will no longer be 100% compatible compared to Prettier.
Since the parsers used are also different, it will no longer be possible to support certain postcss-plugin-specific syntax, invalid syntax or legacy syntax.
> [!WARNING]
> TODO: Move fork under `oxc-project` org and replace refs