Repository navigation
fix(migrate): detect existing staged config with the AST key check #3575
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
fengmk2
merged 4 commits into
voidzero-dev:main
from
jong-kyung:fix/migrate-staged-key-detection
Nov 25, 2026
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
c36026f
fix(migrate): detect existing staged config with the AST key check
jong-kyung cbbd907
Merge branch 'main' into fix/migrate-staged-key-detection
jong-kyung cba290f
Merge branch 'main' into fix/migrate-staged-key-detection
jong-kyung be6e851
Merge branch 'main' into fix/migrate-staged-key-detection
fengmk2 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
16 changes: 16 additions & 0 deletions
16
..._snapshots/tests/cli_snapshots/fixtures/migration_hooks_commented_staged_key/package.json
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| { | ||
| "name": "migration-hooks-commented-staged-key", | ||
| "devDependencies": { | ||
| "vite-plus": "latest" | ||
| }, | ||
| "lint-staged": { | ||
| "*.ts": "vp check --fix" | ||
| }, | ||
| "devEngines": { | ||
| "packageManager": { | ||
| "name": "npm", | ||
| "version": "11.16.0", | ||
| "onFail": "download" | ||
| } | ||
| } | ||
| } |
11 changes: 11 additions & 0 deletions
11
...napshots/tests/cli_snapshots/fixtures/migration_hooks_commented_staged_key/snapshots.toml
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| [[case]] | ||
| name = "migration_hooks_commented_staged_key" | ||
| vp = "global" | ||
| comment = "A commented-out `staged:` must not count as existing staged config, or package.json lint-staged is deleted without being merged." | ||
| skip-platforms = [{ os = "linux", libc = "musl" }] | ||
| steps = [ | ||
| { argv = ["git", "init"], snapshot = false, continue-on-failure = true }, | ||
| { argv = ["vp", "migrate", "--no-interactive", "--hooks"], continue-on-failure = true }, | ||
| { argv = ["vpt", "print-file", "package.json"], comment = "lint-staged should be removed only because it was merged", continue-on-failure = true }, | ||
| { argv = ["vpt", "print-file", "vite.config.ts"], comment = "staged config should be merged from package.json", continue-on-failure = true }, | ||
| ] |
63 changes: 63 additions & 0 deletions
63
...on_hooks_commented_staged_key/snapshots/migration_hooks_commented_staged_key.md
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,63 @@ | ||
| # migration_hooks_commented_staged_key | ||
|
|
||
| A commented-out `staged:` must not count as existing staged config, or package.json lint-staged is deleted without being merged. | ||
|
|
||
| ## `git init` | ||
|
|
||
|
|
||
| ## `vp migrate --no-interactive --hooks` | ||
|
|
||
| ``` | ||
| VITE+ - The Unified Toolchain for the Web | ||
|
|
||
| ◇ Updated . to Vite+ <version> | ||
| • Node <version> npm <version> | ||
| • Dependencies: | ||
| vite-plus latest → <version> | ||
| vite → <version> | ||
| • 1 config update applied | ||
| • Git hooks configured | ||
| • Package manager settings configured | ||
| ``` | ||
|
|
||
| ## `vpt print-file package.json` | ||
|
|
||
| lint-staged should be removed only because it was merged | ||
|
|
||
| ``` | ||
| { | ||
| "name": "migration-hooks-commented-staged-key", | ||
| "devDependencies": { | ||
| "vite-plus": "<version>" | ||
| }, | ||
| "devEngines": { | ||
| "packageManager": { | ||
| "name": "npm", | ||
| "version": "<version>", | ||
| "onFail": "download" | ||
| } | ||
| }, | ||
| "overrides": { | ||
| "vite": "npm:@voidzero-dev/vite-plus-core@<version>" | ||
| }, | ||
| "scripts": { | ||
| "prepare": "vp config" | ||
| } | ||
| } | ||
| ``` | ||
|
|
||
| ## `vpt print-file vite.config.ts` | ||
|
|
||
| staged config should be merged from package.json | ||
|
|
||
| ``` | ||
| import { defineConfig } from 'vite-plus'; | ||
|
|
||
| // TODO: move lint-staged here as staged: { ... } | ||
| export default defineConfig({ | ||
| staged: { | ||
| "*.ts": "vp check --fix" | ||
| }, | ||
|
|
||
| }); | ||
| ``` |
4 changes: 4 additions & 0 deletions
4
...napshots/tests/cli_snapshots/fixtures/migration_hooks_commented_staged_key/vite.config.ts
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| import { defineConfig } from 'vite-plus'; | ||
|
|
||
| // TODO: move lint-staged here as staged: { ... } | ||
| export default defineConfig({}); |
3 changes: 3 additions & 0 deletions
3
.../tests/cli_snapshots/fixtures/migration_lintstagedrc_quoted_staged_key/.lintstagedrc.json
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| { | ||
| "*.css": "stylelint --fix" | ||
| } |
7 changes: 7 additions & 0 deletions
7
...pshots/tests/cli_snapshots/fixtures/migration_lintstagedrc_quoted_staged_key/package.json
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| { | ||
| "name": "migration-lintstagedrc-quoted-staged-key", | ||
| "devDependencies": { | ||
| "lint-staged": "^16.2.6", | ||
| "vite": "^7.0.0" | ||
| } | ||
| } |
10 changes: 10 additions & 0 deletions
10
...hots/tests/cli_snapshots/fixtures/migration_lintstagedrc_quoted_staged_key/snapshots.toml
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| [[case]] | ||
| name = "migration_lintstagedrc_quoted_staged_key" | ||
| vp = "global" | ||
| comment = "A quoted `'staged'` key is existing staged config, so the standalone file must be kept instead of merged as a duplicate key." | ||
| steps = [ | ||
| { argv = ["git", "init"], snapshot = false, continue-on-failure = true }, | ||
| { argv = ["vp", "migrate", "--no-interactive"], comment = "should warn when staged already exists in vite.config.ts", continue-on-failure = true }, | ||
| { argv = ["vpt", "stat-file", ".lintstagedrc.json", "--assert", "file"], comment = "lintstagedrc.json should still exist", continue-on-failure = true }, | ||
| { argv = ["vpt", "print-file", "vite.config.ts"], comment = "vite config should have a single staged key", continue-on-failure = true }, | ||
| ] |
44 changes: 44 additions & 0 deletions
44
...tagedrc_quoted_staged_key/snapshots/migration_lintstagedrc_quoted_staged_key.md
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,44 @@ | ||
| # migration_lintstagedrc_quoted_staged_key | ||
|
|
||
| A quoted `'staged'` key is existing staged config, so the standalone file must be kept instead of merged as a duplicate key. | ||
|
|
||
| ## `git init` | ||
|
|
||
|
|
||
| ## `vp migrate --no-interactive` | ||
|
|
||
| should warn when staged already exists in vite.config.ts | ||
|
|
||
| ``` | ||
| VITE+ - The Unified Toolchain for the Web | ||
|
|
||
| ◇ Migrated . to Vite+ <version> | ||
| • Node <version> pnpm <version> | ||
| • Git hooks configured | ||
| ! Warnings: | ||
| - .lintstagedrc.json found but "staged" already exists in vite.config.ts — please merge manually | ||
| ``` | ||
|
|
||
| ## `vpt stat-file .lintstagedrc.json --assert file` | ||
|
|
||
| lintstagedrc.json should still exist | ||
|
|
||
| ``` | ||
| .lintstagedrc.json: file | ||
| ``` | ||
|
|
||
| ## `vpt print-file vite.config.ts` | ||
|
|
||
| vite config should have a single staged key | ||
|
|
||
| ``` | ||
| import { defineConfig } from 'vite-plus'; | ||
|
|
||
| export default defineConfig({ | ||
| fmt: {}, | ||
| lint: {"jsPlugins":[{"name":"vite-plus","specifier":"vite-plus/oxlint-plugin"}],"rules":{"vite-plus/prefer-vite-plus-imports":"error"},"options":{"typeAware":true,"typeCheck":true}}, | ||
| 'staged': { | ||
| '*.js': 'vp check --fix', | ||
| }, | ||
| }); | ||
| ``` |
7 changes: 7 additions & 0 deletions
7
...hots/tests/cli_snapshots/fixtures/migration_lintstagedrc_quoted_staged_key/vite.config.ts
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| import { defineConfig } from 'vite-plus'; | ||
|
|
||
| export default defineConfig({ | ||
| 'staged': { | ||
| '*.js': 'vp check --fix', | ||
| }, | ||
| }); |
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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.