FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

fix(migrate): emit a single --check when rewriting prettier scripts by shulaoda · Pull Request #2044 · voidzero-dev/vite-plus · GitHub

fix(migrate): emit a single --check when rewriting prettier scripts - #2044

Merged
fengmk2 merged 3 commits into
mainfrom
07-04-fix_migrate_emit_a_single_--check_when_rewriting_prettier_scripts
Jul 4, 2026
Merged

fix(migrate): emit a single --check when rewriting prettier scripts#2044
fengmk2 merged 3 commits into
mainfrom
07-04-fix_migrate_emit_a_single_--check_when_rewriting_prettier_scripts

Conversation

shulaoda commented Jul 4, 2026

Copy link
Copy Markdown
Member

Problem

When migrating a package.json script, prettier flags are rewritten to vp fmt, converting --list-different / -l / -c to --check. If the script also contained a literal --check, the result depended on the flag order:

input before after
prettier --check --list-different . vp fmt --check . vp fmt --check .
prettier --list-different --check . vp fmt --check --check . ❌ vp fmt --check .
prettier --check --check . vp fmt --check --check . ❌ vp fmt --check .

strip_flags_from_suffix (in script_rewrite.rs) converts source flags to the target flag and dedups against a literal dedup_flag. But the dedup branch only set conversion_emitted — it did not drop the literal token or break, so a literal --check that came after a converted flag still fell through to suffix.0.push(item) and was emitted a second time. Only the reverse order (--check first) worked, because the literal was pushed once and the later conversion was suppressed.

Fix

Make the dedup branch symmetric — when the token is the literal dedup_flag:

if val == conv.dedup_flag {
    // Drop a duplicate if the target flag was already emitted;
    // otherwise keep this one and mark it emitted.
    if conversion_emitted[ci] {
        converted = true;
    } else {
        conversion_emitted[ci] = true;
    }
    break;
}

Now the target flag is emitted exactly once regardless of order. The added break is safe: prettier is the only config with a flag_conversions rule and it has exactly one (eslint's is empty), so nothing later in the loop is skipped.

Test

Extended test_rewrite_prettier_list_different_to_check with the two previously-broken orderings — --list-different --check and the double-literal --check --check — both asserting a single vp fmt --check .. They fail on the old code (duplicate --check) and pass on the fix. The full vite_migration suite stays green (293 passed).

Reproduce

cargo test -p vite_migration --lib \
  prettier::tests::test_rewrite_prettier_list_different_to_check

To see the bug: revert the dedup_flag branch to conversion_emitted[ci] = true; (no break) and rerun — the test fails with left: "vp fmt --check --check .".

netlify Bot commented Jul 4, 2026
edited
Loading

Copy link
Copy Markdown

Deploy Preview for viteplus-preview canceled.

Name Link
🔨 Latest commit 5ac7239
🔍 Latest deploy log https://app.netlify.com/projects/viteplus-preview/deploys/6a48ed938b9f350008972bcc

fengmk2 added test: e2e Auto run e2e tests test: create-e2e Run `vp create` e2e tests labels Jul 4, 2026
fengmk2 self-assigned this Jul 4, 2026
fengmk2 merged commit 01360d3 into main Jul 4, 2026
96 checks passed
fengmk2 deleted the 07-04-fix_migrate_emit_a_single_--check_when_rewriting_prettier_scripts branch July 4, 2026 11:45
wan9chi added a commit that referenced this pull request Jul 7, 2026
…xes (#2081)

Release vite-plus v0.2.3: config extraction, create, and `vp run`
reliability fixes.

A patch release that restores static config extraction for projects
importing `defineConfig` from `vite`, fixes `vp create` for org
templates on registries that strip custom package fields, cleans up
terminal output after Ctrl-C during `vp run`, and updates bundled Vite
to 8.1.3.

### Highlights

- **Custom `VP_HOME` is honored on every run**: the global `vp` now
respects a user-set `VP_HOME` for its home directory instead of falling
back to `~/.vite-plus`, and persists it in the generated env files, so a
custom install location no longer produces multiple instances or
unusable packages
([#2029](#2029)), by
@liangmiQwQ

### Features

- Upgrade bundled Vite from `8.1.2` to `8.1.3` (inlined CSS after the
shebang line, CSS preload for nested dynamic imports, SSR stacktrace
column fix)
([#2042](#2042)), by
@voidzero-guard[bot]

### Fixes & Enhancements

- `vp run` no longer misreads a `vite.config.ts` when its `defineConfig`
comes from a preset or a custom wrapper instead of `vite-plus` or
`vite`. Such configs are now evaluated at runtime rather than assumed to
be Vite+'s own, so projects that use them no longer wrongly report `Task
"build" not found`
([#2060](#2060),
[#2075](#2075)), by
@liangmiQwQ and @fengmk2
- Killing a `vp run` task with Ctrl-C no longer leaves odd OSC escape
sequences in the terminal; `vp` defers its own Ctrl-C handling until the
child process exits
([#2079](#2079)), by
@forehalo
- `vp migrate`: rewriting a `package.json` prettier script now emits a
single `--check`, so scripts that combined `--check` with
`--list-different` / `-l` / `-c` no longer produce a duplicated `vp fmt
--check --check`
([#2044](#2044)), by
@shulaoda
- `vp create @org:name`: read the org template catalog (`createConfig`)
from the published tarball when the registry (e.g. GitHub Packages)
strips custom fields from packument metadata
([#2063](#2063)), by
@hiro-daikin
- `vp run`: missing env vars requested through
`@voidzero-dev/vite-task-client` now return `undefined` instead of
`null`, preserving Vite production `NODE_ENV` semantics when builds run
through `vp run`
([vite-task#508](voidzero-dev/vite-task#508),
via [#2076](#2076)), by
@wan9chi

### Refactor

- `static_config`: drop the unreachable `vite.config.json` branch
([#2045](#2045)), and
remove unused exported CLI helpers
([#2046](#2046)), by
@shulaoda

### Docs

- Update the announcement links and callout for the beta release
([#2027](#2027)), remove
the stale `Dockerfile.alpine` comment
([#2068](#2068)), by
@fengmk2
- Add the missing `pnpm-workspace.yaml` to the docs Dockerfile
([#2059](#2059)), by
@wan-kong
- Refresh the root agent guide
([#2072](#2072)), by
@jong-kyung

### Chore

- Cross-compile Windows tests and CLI binaries on Linux with cargo-xwin
([#1824](#1824)), install
local vite-plus builds through a local npm registry
([#2021](#2021)), fast
docs format check for docs-only PRs
([#2028](#2028)), pack
local dirs for the registry bridge instead of pkg.pr.new
([#2038](#2038)), remove
the stale create workflow updater
([#2061](#2061)), and add
PTY-based interactive CLI snapshot tests
([#2052](#2052)), by
@fengmk2
- Cache `vp run` output for docs builds
([#2006](#2006)), by
@wan9chi
- Remove legacy completion cleanup
([#2050](#2050)), by
@nekomoyi
- Update the crate-ci/typos action
([#2039](#2039)) and
GitHub Actions
([#2055](#2055),
[#1905](#1905)), by
@renovate[bot]
- Refresh the Node.js release keyring
([#2058](#2058)) and the
docs trusted-stack stats
([#2064](#2064)), by
@voidzero-guard[bot]

### Bundled Versions

| Tool | Version | Source |
| --- | --- | --- |
| vite | `8.1.3` |
[`578ffb8`](vitejs/vite@578ffb8)
|
| rolldown | `1.1.4` |
[`6cbd233`](rolldown/rolldown@6cbd233)
|
| tsdown | `0.22.3` | [npm](https://npmx.dev/package/tsdown/v/0.22.3) |
| vitest | `4.1.9` | [npm](https://npmx.dev/package/vitest/v/4.1.9) |
| oxlint | `1.72.0` | [npm](https://npmx.dev/package/oxlint/v/1.72.0) |
| oxlint-tsgolint | `0.24.0` |
[npm](https://npmx.dev/package/oxlint-tsgolint/v/0.24.0) |
| oxfmt | `0.57.0` | [npm](https://npmx.dev/package/oxfmt/v/0.57.0) |

### Upgrade

```bash
vp upgrade
```

### New Contributors

@wan-kong and @hiro-daikin made their first contributions.

**Full Changelog**:
v0.2.2...v0.2.3

---

Merging this PR will trigger the release workflow.

---------

Co-authored-by: voidzero-guard[bot] <278573678+voidzero-guard[bot]@users.noreply.github.com>
Co-authored-by: wan9chi <dk4rest@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

test: create-e2e Run `vp create` e2e tests test: e2e Auto run e2e tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants


Back | FazBrowse Home | New Git URL