Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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"
}
}
}
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 },
]
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"
},

});
```
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({});
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"*.css": "stylelint --fix"
}
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"
}
}
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 },
]
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',
},
});
```
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',
},
});
4 changes: 1 addition & 3 deletions packages/cli/src/migration/migrator/vite-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -938,9 +938,7 @@ export function hasStagedConfigInViteConfig(projectPath: string): boolean {
if (!configs.viteConfig) {
return false;
}
const viteConfigPath = path.join(projectPath, configs.viteConfig);
const content = fs.readFileSync(viteConfigPath, 'utf8');
return /\bstaged\s*:/.test(content);
return hasConfigKey(path.join(projectPath, configs.viteConfig), 'staged');
Comment thread
jong-kyung marked this conversation as resolved.
Resolved
}

/**
Expand Down
Loading