test(oxfmt): Add js-in-xxx prettier conformance#19563
Conversation
How to use the Graphite Merge QueueAdd either label to this PR to merge it via the merge queue:
You must have a Graphite account in order to use the merge queue. Sign up using this link. An organization admin has enabled the Graphite Merge Queue in this repository. Please do not merge from GitHub as this will restart CI on PRs being processed by the merge queue. This stack of pull requests is managed by Graphite. Learn more about stacking. |
fb777c3 to
0b4bf60
Compare
0b4bf60 to
75d48b7
Compare
There was a problem hiding this comment.
Pull request overview
This PR adds conformance tests to verify that oxfmt's output matches Prettier's output for Vue files (and prepares infrastructure for other file types). The tests download Prettier's official test fixtures from their repository and compare formatting results between oxfmt and Prettier.
Changes:
- Added a new conformance test suite that compares oxfmt formatting output with Prettier's output for Vue files
- Added a script to download Prettier test fixtures from their repository using degit
- Added degit as a dev dependency to enable downloading fixtures
- Updated .gitignore to exclude downloaded fixtures from version control
Reviewed changes
Copilot reviewed 4 out of 5 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| pnpm-lock.yaml | Adds degit dependency lock entry |
| apps/oxfmt/test/api/js-in-xxx-conformance.test.ts | New conformance test suite that collects Vue fixtures and compares oxfmt vs prettier formatting with multiple option configurations |
| apps/oxfmt/scripts/download-prettier-fixtures.js | Script to download prettier test fixtures using degit from the prettier repository |
| apps/oxfmt/package.json | Adds download-prettier-fixtures script and degit dev dependency |
| apps/oxfmt/.gitignore | Excludes prettier-fixtures directory from git |
Files not reviewed (1)
- pnpm-lock.yaml: Language not supported
291d96b to
7fe1a05
Compare
d6fa641 to
cf1530c
Compare
7fe1a05 to
3b495e4
Compare
Merge activity
|
Add conformance test `assert(oxfmt(vueFile) === prettier(vueFile))`. Currently, fixtures are downloaded individually and are not executed in CI. It might have been better to change CI to download prettier's submodules and refer to them?, but for now.
### Overview Part of #16608 This PR applies `oxc_formatter` to the js-in-vue section. However, it is not complete and is only applied to the following parts within js-in-vue: - `script` block - and `generic="..."` - `v-for` LHS - `v-slot` In the `script` block, `external_callback` is used like a regular JS file, but it isn't for others. TL;DR: Now you can use sort-imports for Vue files. ### Review points The points I'd like to ask your review are the following: - Addition of `format_node()` to `oxc_formatter` - Made it possible to process any type that implements `Format`, not just `Program` - The implementation of `js-in-vue` fragment was separated as much as possible to avoid impacting existing code - `oxc_formatter` IR to prettier `Doc` ### TODOs - [x] Planning - [x] Implementation - [x] Check benchmark - [x] Check coverage - [x] Understand & refactor - [x] oxfmt: JS side - [x] oxfmt: Rust side - [x] oxfmt: to_doc.rs - [x] oxc_formatter: fragment_format - [x] Check benchmark again - [x] Check coverage again - [x] Check ecosystem-ci - [x] Tests 👉🏻 #19563
3b495e4 to
035933c
Compare
cf1530c to
4ce37b0
Compare

Add conformance test
assert(oxfmt(vueFile) === prettier(vueFile)).Currently, fixtures are downloaded individually and are not executed in CI.
It might have been better to change CI to download prettier's submodules and refer to them?, but for now.