Skip to content

feat(migrate): Prettier → Oxfmt migration via vp fmt --migrate=prettier#742

Merged
fengmk2 merged 5 commits intomainfrom
prettier-migrate
Mar 10, 2026
Merged

feat(migrate): Prettier → Oxfmt migration via vp fmt --migrate=prettier#742
fengmk2 merged 5 commits intomainfrom
prettier-migrate

Conversation

@fengmk2
Copy link
Copy Markdown
Member

@fengmk2 fengmk2 commented Mar 9, 2026

Add Prettier → Oxfmt migration support to vp migrate, following the
same architecture as the existing ESLint → Oxlint migration: Rust shell
script rewriter → NAPI binding → TypeScript orchestration.

  • Rust rewriter rewrites prettiervp fmt, strips Prettier-only
    flags (--write, --cache, --single-quote, --config, --plugin, etc.),
    and converts --list-different/-l → --check
  • Detects all Prettier config files (.prettierrc*, prettier.config.*,
    package.json#prettier) and .prettierignore
  • Removes prettier + prettier-plugin-* dependencies
  • Rewrites scripts in package.json and lint-staged configs
  • Supports both fresh migration and re-migration (already-vite-plus)
  • Includes snap test fixtures for basic, rerun, lint-staged, and
    eslint+prettier combo scenarios

@netlify
Copy link
Copy Markdown

netlify bot commented Mar 9, 2026

Deploy Preview for viteplus-staging ready!

Name Link
🔨 Latest commit 74a2f23
🔍 Latest deploy log https://app.netlify.com/projects/viteplus-staging/deploys/69af77bbc669540007e5868d
😎 Deploy Preview https://deploy-preview-742--viteplus-staging.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

Copy link
Copy Markdown
Member Author

fengmk2 commented Mar 9, 2026

@fengmk2 fengmk2 force-pushed the prettier-migrate branch 2 times, most recently from ba4a067 to 9297fc5 Compare March 9, 2026 13:58
@fengmk2 fengmk2 force-pushed the improve-vp-check branch from 5a4c483 to 6237268 Compare March 9, 2026 13:58
@fengmk2 fengmk2 force-pushed the prettier-migrate branch 2 times, most recently from 98e8aa0 to fc66d6d Compare March 9, 2026 14:29
@fengmk2 fengmk2 force-pushed the improve-vp-check branch from 4b5b347 to 56dfed9 Compare March 9, 2026 14:29
@fengmk2 fengmk2 force-pushed the prettier-migrate branch 4 times, most recently from 5e41e14 to 71501d6 Compare March 9, 2026 15:51
@fengmk2 fengmk2 marked this pull request as ready for review March 9, 2026 15:53
@fengmk2 fengmk2 added the test: e2e Auto run e2e tests label Mar 9, 2026
@fengmk2 fengmk2 force-pushed the prettier-migrate branch 2 times, most recently from 76ebad7 to a3b339c Compare March 9, 2026 16:28
@fengmk2 fengmk2 changed the base branch from improve-vp-check to graphite-base/742 March 9, 2026 17:04
@fengmk2 fengmk2 force-pushed the prettier-migrate branch from a3b339c to d474603 Compare March 9, 2026 17:05
@fengmk2 fengmk2 force-pushed the graphite-base/742 branch from 69220fb to 189d2b3 Compare March 9, 2026 17:05
@fengmk2 fengmk2 force-pushed the prettier-migrate branch from d474603 to 71674aa Compare March 9, 2026 17:05
@graphite-app graphite-app bot changed the base branch from graphite-base/742 to main March 9, 2026 17:06
@fengmk2 fengmk2 force-pushed the prettier-migrate branch 2 times, most recently from 53095a1 to 62bbc40 Compare March 9, 2026 17:20
Copy link
Copy Markdown
Member Author

fengmk2 commented Mar 10, 2026

Merge activity

  • Mar 10, 1:29 AM UTC: A user started a stack merge that includes this pull request via Graphite.
  • Mar 10, 1:30 AM UTC: Graphite rebased this pull request as part of a merge.
  • Mar 10, 1:46 AM UTC: Graphite rebased this pull request as part of a merge.
  • Mar 10, 1:58 AM UTC: Graphite couldn't merge this PR because it was not satisfying all requirements (Failed CI: 'done', 'CLI E2E test (namespace-profile-mac-default)').
  • Mar 10, 2:04 AM UTC: A user started a stack merge that includes this pull request via Graphite.
  • Mar 10, 2:04 AM UTC: @fengmk2 merged this pull request with Graphite.

fengmk2 added 5 commits March 10, 2026 01:45
Add Prettier → Oxfmt migration support to `vp migrate`, following the
same architecture as the existing ESLint → Oxlint migration: Rust shell
script rewriter → NAPI binding → TypeScript orchestration.

- Rust rewriter rewrites `prettier` → `vp fmt`, strips Prettier-only
  flags (--write, --cache, --single-quote, --config, --plugin, etc.),
  and converts --list-different/-l → --check
- Detects all Prettier config files (.prettierrc*, prettier.config.*,
  package.json#prettier) and .prettierignore
- Removes prettier + prettier-plugin-* dependencies
- Rewrites scripts in package.json and lint-staged configs
- Supports both fresh migration and re-migration (already-vite-plus)
- Includes snap test fixtures for basic, rerun, lint-staged, and
  eslint+prettier combo scenarios
…gration

When Prettier config lives in package.json ("prettier" key) rather than a
standalone file, extract it to a temporary .prettierrc.json so that
`vp fmt --migrate=prettier` can read and convert it to .oxfmtrc.json.
Previously the settings were lost because the migration step was skipped
but deletePrettierConfigFiles still removed pkg.prettier.
…prettier rewrite

- Remove --ignore-path from PRETTIER_ONLY_VALUE_FLAGS since vp fmt
  supports this flag
- Add --experimental-cli to PRETTIER_ONLY_BOOLEAN_FLAGS so it gets
  stripped (fixes vitepress E2E failure)
…rewrite module

prettier.rs and eslint.rs had ~85-90% identical code for shell AST walking,
command renaming, and flag stripping. Extract all shared logic into a new
script_rewrite.rs with a ScriptRewriteConfig struct capturing tool-specific
differences (command name, subcommand, flag lists, flag conversions).
…rewrite

`prettier -c .` now correctly rewrites to `vp fmt --check .` and
`prettier -w .` to `vp fmt .`.
@fengmk2 fengmk2 merged commit c0c8ebd into main Mar 10, 2026
48 of 50 checks passed
@fengmk2 fengmk2 deleted the prettier-migrate branch March 10, 2026 02:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

test: e2e Auto run e2e tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants