Commit Graph

19 Commits

Author SHA1 Message Date
leaysgur 0f4af5d7df test(formatter_tests): assert fingerprint survives formatting (#26322)
Historically, only JS formatter has had the `detect_code_removal` feature, which uses CI to check for missing nodes or comments.

While this would be useful in other languages (especially CSS), but setting up the mechanism is difficult. For now, just start with something simple that just guarantees the number of comments.

That said, even with a mechanism in place, it can't detect anything unless the cases are fully covered by fixtures, so this only tells us that the current state is problem-free.
2026-09-04 07:14:53 +00:00
leaysgur f94b22296c test(formatter,formatter_css,formatter_json,formatter_yaml): restore coverage lost in fixture consolidation (#26129)
- Restore wrongly consolidated fixtures
- State new fixtures policy and apply
- Check `endOfLine` option and output at test harness level
2026-08-27 06:12:52 +00:00
leaysgur 9a2e378d25 test(formatter_json): consolidate redundant fixtures (#26122)
Mainly remove redundant fixtures.
2026-08-27 05:33:58 +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 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 0a6b16c424 fix(formatter_json): preserve key and literal value for json-stringify (#23996)
Part of #23923

Do not transform object key, string and number values with `json-stringify`.
2026-07-03 07:22:00 +00:00
leaysgur f21ed2c112 fix(formatter_json): normalize CRLF for suppressed text (#23702)
The same as #23701, for JSON formatter.
2026-06-22 05:32:31 +00:00
leaysgur b0b5d399df fix(formatter_json): support JSON5/JSON6 value in json/jsonc/json5 (#23193)
I wouldn't be surprised by any value that can be formatted as JSON...
2026-06-10 05:41:02 +00:00
leaysgur 8cc82c4cdb feat(formatter_json): implement json-stringify variant (#23192)
Implement last missing JSON family variant: `json-stringify`.

Format output matches `prettier@3.8.4` for now, but we know `prettier@3.9.0` will be coming soon.

> https://github.com/prettier/prettier/blob/main/changelog_unreleased/json/18405.md

So I also implemented this and disabled under `COMPAT_PRE_18405` flag.
2026-06-10 05:41:02 +00:00
leaysgur 8925998899 test(formatter_json): add real world .json5 fixtures (#23111) 2026-06-08 08:39:12 +00:00
leaysgur 3da77e0080 feat(oxfmt): format parser:json5 files by oxc_formatter_json (#22990)
Now, `.json5` is also formatted by `oxc_formatter_json`.
2026-06-08 08:12:35 +00:00
leaysgur 5778a2dfb5 refactor(formatter_core): purify core and define rules (#22952)
The Printer never consumes these; they belong with each language formatter.

- Evict `Quote` (each formatter owns `QuoteStyle`)
  - `normalize_string` takes a quote byte
- Evict `Expand` / `BracketSpacing` / `TrailingCommas` into oxc_formatter and oxc_formatter_json
- JSON's `TrailingCommas` is now two-variant (`Always`/`Never`)
  - collapse Prettier's `all`/`es5` at each translation layer
- Rename `util/` -> `spec/` (pure shared helpers)
- Split `SourceText`: mechanical access stays in core, JS/TS lexis moves to `SourceTextExt`
- Drop the `oxc_syntax` dependency from core

All behaviros, Prettier conformance are unchanged.
2026-06-04 07:03:56 +00:00
leaysgur 27a6db879b feat(formatter_json): implement jsonc variant (#22912)
Implement `oxc_formatter_json`'s `Jsonc` variant.

The difference between `json` and `jsonc`:

- `jsonc` allows comment only input, `json` does not
- `jsonc` refers `trailingComma` option, `json` does not
2026-06-04 06:45:21 +00:00
leaysgur 136b72b09b fix(formatter_json): use line_suffix for line comment outside array (#22931)
Input:
```json
[1, 2, 3] // if this comment is too long and >= printWidth
```

Before:
```json
[
  1,
  2,
  3
] // if this comment is too long and >= printWidth
```

After:
```json
[1, 2, 3] // if this comment is too long and >= printWidth
```
2026-06-03 04:19:22 +00:00
leaysgur 44e40fa94c fix(formatter_json): expand line comment inside array (#22911)
Fix the bug:

```json
[1,2 // x
]
```

is printed as like:

```json
[1,2 // x]
```
2026-06-03 03:16:08 +00:00
leaysgur 5733868456 refactor(formatter_core,formatter,formatter_json): share Expand and BracketSpacing options (#22821)
We chose `core` as the location for duplicate `struct`s, but the final options will continue to be built by each formatter.
2026-05-29 09:13:38 +00:00
leaysgur e4a89ec5fe refactor(formatter): Share fixtures test harness and test formatter_json (#22676)
Extract the fixture-based snapshot test harness from `oxc_formatter` into two `oxc_formatter_core` modules behind a `test_harness` feature:

- `test_support/codegen`:
  - Language-agnostic `build.rs` helper that walks `tests/fixtures/` and emits `#[test]` functions to `$OUT_DIR`
  - Extension allowlist is now a parameter instead of hardcoded JS types.
- `test_support/harness`:
  - Snapshot-runtime that drives one format pass per option set × per printWidth (80, 100) and asserts via `insta`
  - Per-language hook is the new `FixtureFormatter` trait
2026-05-29 00:49:50 +00:00