Commit Graph

47 Commits

Author SHA1 Message Date
leaysgur 5c0a5ff7bf fix(formatter_css): fill own-line block comments inside space-separated values (#25578)
Fixed idempotency issue.

Block comment is a normal fill item in values.
2026-08-13 07:45:25 +00:00
leaysgur 53debfa10e fix(formatter_css): keep trailing comma and indent after comment-preceded last map value (#25577)
Fixed idempotency issue.

```scss
$with-comment_n_comma: (
  a: (
    x: 1,
  ),
  /* This comment should not affect trailing comma, indent depth */
  b: (
    x: 2,
  ),
);
```
2026-08-13 07:45:25 +00:00
leaysgur 40d38a0813 fix(formatter_css): keep multi value function args intact after leading comment (#25518)
Fixes #25480
2026-08-12 05:36:15 +00:00
leaysgur 4544183058 test(formatter_tests,formatter,formatter_css): always track idempotency violations in snapshots (#25512)
Trackable easier than before.
2026-08-12 02:25:55 +00:00
leaysgur b63e88a0b4 test(formatter_css): pin more known divergence (#25479)
Found cases that had been discarded due to runner bugs before.
2026-08-12 00:48:33 +00:00
leaysgur b297fb1cb8 refactor(formatter,formatter_tests): fix up (#25478)
Cleaning up after the series of migrations.

- Docs clean up
- More strict `jsdoc` option handling in fixture tests
2026-08-12 00:48:33 +00:00
leaysgur e4437275de refactor(formatter_css,formatter_json,formatter_graphql,formatter_tests): move out prettier CSS,JSON,GraphQL conformance from tasks/ (#25472)
Migration from tasks/prettier_conformance to each crate test using oxc_formatter_tests, for CSS, JSON, and GraphQL.
2026-08-12 00:48:32 +00:00
leaysgur 6e1b4ddceb refactor(formatter_core,formatter_tests): extract oxc_formatter_tests crate from oxc_formatter_core (#25465)
- Extract `test_harness` feature as crate `oxc_formatter_tests`
- This crate will also provide infra for `tasks/prettier_conformance` later
2026-08-12 00:40:59 +00:00
leaysgur d9749a747d refactor(formatter_core,formatter): enforce finalize-once behind the print (#25425)
Follow the rule, #25328.
2026-08-09 14:59:36 +00:00
leaysgur 465b723d04 refactor(formatter,oxfmt): unify host services as SessionServices on FormatSession (#25388)
- dispatcher
- string_embedder
- tailwind_sorter

Group these 3 together as `SessionServices`, make them available to `FormatSession`, and pass them around.
2026-08-09 14:32:10 +00:00
leaysgur 52b146f025 refactor(formatter_core): share split_bom helper (#25333)
In order to standardise the handling of front matter, it was also necessary to standardise the handling of the BOM, which may appear before the FM.
2026-08-09 13:06:35 +00:00
leaysgur b3ad060cfd refactor(formatter): migrate embedded entries to FormatSession (#25332)
Apply `FormatSession` everywhere introduced in #25329.
2026-08-09 13:06:35 +00:00
leaysgur e23dccf338 fix(formatter_css): bump oxc-css-parser to accept unknown at-rule with interpolated (#25277)
Fixes #25272
2026-08-04 06:39:46 +00:00
leaysgur 8c2ed1a04f test(formatter_css): add grid arg re-wrap fixture (#25229)
Follow up #25226
2026-08-03 02:49:01 +00:00
leaysgur 68146bd3b9 fix(formatter_css): preserve glued plugin words in grid values (#25225)
Fixes #25223
2026-08-03 02:00:00 +00:00
leaysgur 96a9744198 refactor(formatter_core): export apply_core_options for tests (#25139)
The same as #25138, for fixture tests.
2026-07-31 08:11:23 +00:00
leaysgur dd28596d0a fix(formatter_css): bump oxc-css-parser for substituted at-rule preludes (#25104)
Fixes #25075
2026-07-30 03:28:44 +00:00
leaysgur f56009a676 fix(oxfmt): correct prose about comment width in fits measurement (#25054)
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.
2026-07-29 02:57:17 +00:00
leaysgur 761a882a49 fix(formatter_css): keep leading + in An+B to enable idempotency check (#24973)
Keep `:nth-child(+3n + 1)` as-is, NOT `:nth(+ 3n + 1)` which is not allowed.
2026-07-27 09:07:31 +00:00
leaysgur ae1a39b71c fix(formatter_css): align wrapped selector-arg indent (#24971)
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.
2026-07-27 06:47:19 +00:00
leaysgur fb34196ec7 fix(formatter_css): keep non-ASCII strings with quotes (#24870)
Fixes #24841
2026-07-24 02:13:21 +00:00
leaysgur cb9655da3e test(formatter_core): assert fixture idempotency in test harness (#24819)
Automatically test idempotency with fixture tests.

Currently, JS and CSS formatter have the issue, will fix later to enable.
2026-07-23 04:51:26 +00:00
leaysgur 31783e997c fix(formatter_css): print nested SCSS map with consistent indent (#24789)
Fixes #24773
2026-07-22 01:58:53 +00:00
leaysgur fd7cf5b500 fix(formatter_css): update oxc-css-parser to 0.0.9 (#24745)
Fixes #24726
2026-07-21 04:52:30 +00:00
leaysgur c399367877 fix(formatter_css): update oxc-css-parser to 0.0.8 (#24725)
This also fixes #24723
2026-07-20 13:37:52 +00:00
leaysgur 33e32d8e51 fix(formatter_css): use line_suffix for EOL line comment (#24580)
The same motivation as #24579
2026-07-16 01:37:31 +00:00
leaysgur 95262b9d94 fix(formatter_css): keep more value comments before comma (#24487)
Follow up on #24484.

Apply the same rule for all call sites.
2026-07-14 06:28:50 +00:00
leaysgur cd53d98460 fix(formatter_css): keep value comments before comma (#24484)
Fixes #24469

This keeps comments before/after `,` stay the same position.
2026-07-14 06:28:49 +00:00
leaysgur 0173cd37a3 feat(formatter_css): format Less :extend and merge props (#24358)
Follows:

- https://github.com/prettier/prettier/pull/19550
- https://github.com/prettier/prettier/pull/19517
2026-07-13 00:13:32 +00:00
leaysgur fcc28dfc9c fix(formatter_css): Keep glued-braket-value tight (#24352)
Fixes #24334
2026-07-13 00:08:30 +00:00
leaysgur eeabc4a55f fix(formatter_css): bail on EOF-recovered parse errors (#24282)
Also updated the code to reflect the changes in `oxc-css-parser` 0.0.6.
2026-07-08 02:17:08 +00:00
leaysgur 9af383371b fix(formatter_css): make scss formatter consistent (#24207)
Fix `@use`, `@forward` and its comment printing.
2026-07-06 06:01:17 +00:00
leaysgur 46d7194d9d fix(formatter_css): use fill IR for @forward members (#24206)
This will ensure that line breaks are inserted taking `printWidth` into account.
2026-07-06 06:01:17 +00:00
leaysgur e31038f0cf fix(formatter_css): keep comment inside sass config list (#24205)
Fixes #24193

Now comments inside `@use`/`@forward` + `with ()` are preserved.
2026-07-06 06:01:16 +00:00
leaysgur 4f4313ef47 feat(formatter_css): update oxc-css-parser 0.0.5 (#24120)
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).
2026-07-03 14:06:30 +00:00
leaysgur 9bf4b4a56b fix(formatter_css): align CSS output to Prettier 3.9.1 (#24100)
Part of #23923

These changes were not listed in `changelog_unreleased`.
2026-07-03 07:29:32 +00:00
leaysgur cd2452e170 fix(formatter_css): align SCSS output to Prettier 3.9.1 (#24097)
Part of #23923

Addressed these changes:

- https://github.com/prettier/prettier/blob/79f6cdfd9873a91be9b25c9c6a41d26dcd9a6656/changelog_unreleased/scss/18530.md
- https://github.com/prettier/prettier/blob/79f6cdfd9873a91be9b25c9c6a41d26dcd9a6656/changelog_unreleased/scss/18535.md
- https://github.com/prettier/prettier/blob/79f6cdfd9873a91be9b25c9c6a41d26dcd9a6656/changelog_unreleased/scss/19091.md

and also fixed minor formatting diffs regarding to trailing comment in map.

```scss
$m: (
  a: 1,
  b: 2, // THIS
);
```
2026-07-03 07:29:32 +00:00
leaysgur 903ab6eee1 fix(formatter_css): preserve newlines in css-in-js selector list (#23992)
```tsx
const Card = styled.div`
  /* Keep these newlines! */
  ${p7}:hover &,
  ${p8}:focus-within &,
  ${p9}:after { color: red; }
  ${p10}:after,
  ${p11}:hover & {
    color:blue
  }
`;
```
2026-07-01 03:03:40 +00:00
leaysgur e0b35a1a5b feat(formatter_css): update oxc-css-parser@0.0.3 (#23974)
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).
2026-07-01 02:16:59 +00:00
leaysgur dd5d39ec2e refactor(formatter_css): use try_parsing_value_in_custom_property option (#23968)
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.
2026-06-30 02:31:53 +00:00
leaysgur dbf27196fc chore(formatter_css): use oxc-css-parser (#23920) 2026-06-29 04:15:34 +00:00
leaysgur 692c73aae5 refactor(oxfmt,formatter_css): rework css-in-js with substituion (#23787)
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.
2026-06-29 03:54:45 +00:00
leaysgur 78eba8c00e refactor(formatter_css): fix up code and comments (#23704)
Finally fixed up Fable's work.
(There is no need to replicate Prettier bugs as-is!)
2026-06-29 03:15:27 +00:00
leaysgur 48e2d7855b fix(formatter_css): improve major prettier diffs (#23327)
Fixed many formatting diffs by checking real world repo.
2026-06-29 03:15:26 +00:00
leaysgur 72a5d0887a refactor(oxfmt): use unified embedded ir results (#23325)
- Add `EmbeddedIr` struct in `oxc_formatter_core`
- Each `format_to_ir` implementation returns this as unified result
2026-06-29 03:15:25 +00:00
leaysgur 43aa5fe1ef refactor(formatter_css): update oxc_formatter_css to support sortTailwindcss option (#23323)
- 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
2026-06-29 03:15:24 +00:00
leaysgur accbc49def feat(oxfmt)!: format parser:css,less,scss files + css-in-js by oxc_formatter_css (#23321)
- 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
2026-06-29 03:15:24 +00:00