diff --git a/crates/vp_cli_snapshots/tests/cli_snapshots/fixtures/migration_eslint_legacy_already_vite_plus/snapshots.toml b/crates/vp_cli_snapshots/tests/cli_snapshots/fixtures/migration_eslint_legacy_already_vite_plus/snapshots.toml index 8a8c12bacd..a3e91ce319 100644 --- a/crates/vp_cli_snapshots/tests/cli_snapshots/fixtures/migration_eslint_legacy_already_vite_plus/snapshots.toml +++ b/crates/vp_cli_snapshots/tests/cli_snapshots/fixtures/migration_eslint_legacy_already_vite_plus/snapshots.toml @@ -3,5 +3,7 @@ name = "migration_eslint_legacy_already_vite_plus" vp = "global" skip-platforms = [{ os = "linux", libc = "musl" }] steps = [ - { argv = ["vp", "migrate", "--no-interactive"], comment = "should show legacy config warning and already using Vite+", continue-on-failure = true }, + { argv = ["vp", "migrate", "--full", "--no-interactive"], comment = "full migration of an existing Vite+ project should warn about the legacy ESLint config and skip ESLint migration", continue-on-failure = true }, + { argv = ["vpt", "print-file", "package.json"], comment = "check eslint and its lint script are kept", continue-on-failure = true }, + { argv = ["vpt", "stat-file", ".eslintrc", "--assert", "file"], comment = "check legacy config is kept", continue-on-failure = true }, ] diff --git a/crates/vp_cli_snapshots/tests/cli_snapshots/fixtures/migration_eslint_legacy_already_vite_plus/snapshots/migration_eslint_legacy_already_vite_plus.md b/crates/vp_cli_snapshots/tests/cli_snapshots/fixtures/migration_eslint_legacy_already_vite_plus/snapshots/migration_eslint_legacy_already_vite_plus.md index 481b081c2a..a15cd463ed 100644 --- a/crates/vp_cli_snapshots/tests/cli_snapshots/fixtures/migration_eslint_legacy_already_vite_plus/snapshots/migration_eslint_legacy_already_vite_plus.md +++ b/crates/vp_cli_snapshots/tests/cli_snapshots/fixtures/migration_eslint_legacy_already_vite_plus/snapshots/migration_eslint_legacy_already_vite_plus.md @@ -1,17 +1,44 @@ # migration_eslint_legacy_already_vite_plus -## `vp migrate --no-interactive` +## `vp migrate --full --no-interactive` -should show legacy config warning and already using Vite+ +full migration of an existing Vite+ project should warn about the legacy ESLint config and skip ESLint migration ``` VITE+ - The Unified Toolchain for the Web +▲ Legacy ESLint configuration detected (.eslintrc). Automatic migration to Oxlint requires ESLint v9+ with flat config format (eslint.config.*). Please upgrade to ESLint v9 first: https://eslint.org/docs/latest/use/migrate-to-9.0.0 ◇ Updated . to Vite+ • Node pnpm • Dependencies: vite-plus latest → vite → +• 2 config updates applied • Package manager settings configured -• Skipped editor, hooks, and lint setup. Run `vp migrate --full` to apply them. +``` + +## `vpt print-file package.json` + +check eslint and its lint script are kept + +``` +{ + "name": "migration-eslint-legacy-already-vite-plus", + "scripts": { + "lint": "eslint .", + "prepare": "vp config" + }, + "devDependencies": { + "eslint": "^8.23.1", + "vite-plus": "catalog:" + } +} +``` + +## `vpt stat-file .eslintrc --assert file` + +check legacy config is kept + +``` +.eslintrc: file ``` diff --git a/crates/vp_cli_snapshots/tests/cli_snapshots/fixtures/migration_eslint_rerun/snapshots.toml b/crates/vp_cli_snapshots/tests/cli_snapshots/fixtures/migration_eslint_rerun/snapshots.toml index 2d37576d70..f58e6a3477 100644 --- a/crates/vp_cli_snapshots/tests/cli_snapshots/fixtures/migration_eslint_rerun/snapshots.toml +++ b/crates/vp_cli_snapshots/tests/cli_snapshots/fixtures/migration_eslint_rerun/snapshots.toml @@ -3,7 +3,7 @@ name = "migration_eslint_rerun" vp = "global" skip-platforms = [{ os = "linux", libc = "musl" }] steps = [ - { argv = ["vp", "migrate", "--no-interactive"], comment = "should detect vite-plus + eslint and auto-migrate eslint", continue-on-failure = true }, + { argv = ["vp", "migrate", "--full", "--no-interactive"], comment = "should detect vite-plus + eslint and auto-migrate eslint", continue-on-failure = true }, { argv = ["vpt", "print-file", "package.json"], comment = "check eslint removed from devDependencies and scripts rewritten", continue-on-failure = true }, { argv = ["vpt", "stat-file", "eslint.config.mjs", "--assert-not", "file"], comment = "check eslint config is removed", continue-on-failure = true }, { argv = ["vpt", "print-file", "vite.config.ts"], comment = "check oxlint config merged into vite.config.ts", continue-on-failure = true }, diff --git a/crates/vp_cli_snapshots/tests/cli_snapshots/fixtures/migration_eslint_rerun/snapshots/migration_eslint_rerun.md b/crates/vp_cli_snapshots/tests/cli_snapshots/fixtures/migration_eslint_rerun/snapshots/migration_eslint_rerun.md index d510eba890..6819305890 100644 --- a/crates/vp_cli_snapshots/tests/cli_snapshots/fixtures/migration_eslint_rerun/snapshots/migration_eslint_rerun.md +++ b/crates/vp_cli_snapshots/tests/cli_snapshots/fixtures/migration_eslint_rerun/snapshots/migration_eslint_rerun.md @@ -1,6 +1,6 @@ # migration_eslint_rerun -## `vp migrate --no-interactive` +## `vp migrate --full --no-interactive` should detect vite-plus + eslint and auto-migrate eslint @@ -12,8 +12,9 @@ VITE+ - The Unified Toolchain for the Web • Dependencies: vite-plus latest → vite → +• 4 config updates applied +• ESLint rules migrated to Oxlint • Package manager settings configured -• Skipped editor, hooks, and lint setup. Run `vp migrate --full` to apply them. ``` ## `vpt print-file package.json` @@ -24,10 +25,10 @@ check eslint removed from devDependencies and scripts rewritten { "name": "migration-eslint-rerun", "scripts": { - "lint": "eslint ." + "lint": "vp lint .", + "prepare": "vp config" }, "devDependencies": { - "eslint": "^9.0.0", "vite-plus": "catalog:" } } @@ -37,20 +38,47 @@ check eslint removed from devDependencies and scripts rewritten check eslint config is removed -**Exit code:** 1 - ``` -eslint.config.mjs: file -stat-file assertion failed +eslint.config.mjs: missing ``` ## `vpt print-file vite.config.ts` check oxlint config merged into vite.config.ts -**Exit code:** 1 - ``` -vite.config.ts: not found -missing file +import { defineConfig } from 'vite-plus'; + +export default defineConfig({ + staged: { + "*": "vp check --fix" + }, + lint: { + "plugins": [ + "oxc", + "typescript", + "unicorn" + ], + "categories": { + "correctness": "warn" + }, + "env": { + "builtin": true + }, + "rules": { + "no-unused-vars": "error", + "vite-plus/prefer-vite-plus-imports": "error" + }, + "options": { + "typeAware": true, + "typeCheck": true + }, + "jsPlugins": [ + { + "name": "vite-plus", + "specifier": "vite-plus/oxlint-plugin" + } + ] + }, +}); ``` diff --git a/crates/vp_cli_snapshots/tests/cli_snapshots/fixtures/migration_eslint_rerun_dual_config/snapshots.toml b/crates/vp_cli_snapshots/tests/cli_snapshots/fixtures/migration_eslint_rerun_dual_config/snapshots.toml index 10d491f921..c7acc38223 100644 --- a/crates/vp_cli_snapshots/tests/cli_snapshots/fixtures/migration_eslint_rerun_dual_config/snapshots.toml +++ b/crates/vp_cli_snapshots/tests/cli_snapshots/fixtures/migration_eslint_rerun_dual_config/snapshots.toml @@ -3,7 +3,7 @@ name = "migration_eslint_rerun_dual_config" vp = "global" skip-platforms = [{ os = "linux", libc = "musl" }] steps = [ - { argv = ["vp", "migrate", "--no-interactive"], comment = "should detect vite-plus + eslint and auto-migrate eslint", continue-on-failure = true }, + { argv = ["vp", "migrate", "--full", "--no-interactive"], comment = "should detect vite-plus + eslint and auto-migrate eslint", continue-on-failure = true }, { argv = ["vpt", "print-file", "package.json"], comment = "check eslint removed and scripts rewritten", continue-on-failure = true }, { argv = ["vpt", "stat-file", "eslint.config.mjs", "--assert-not", "file"], comment = "check flat config is removed", continue-on-failure = true }, { argv = ["vpt", "stat-file", ".eslintrc", "--assert-not", "file"], comment = "check legacy config is also removed", continue-on-failure = true }, diff --git a/crates/vp_cli_snapshots/tests/cli_snapshots/fixtures/migration_eslint_rerun_dual_config/snapshots/migration_eslint_rerun_dual_config.md b/crates/vp_cli_snapshots/tests/cli_snapshots/fixtures/migration_eslint_rerun_dual_config/snapshots/migration_eslint_rerun_dual_config.md index c0b5087dee..9a340ac852 100644 --- a/crates/vp_cli_snapshots/tests/cli_snapshots/fixtures/migration_eslint_rerun_dual_config/snapshots/migration_eslint_rerun_dual_config.md +++ b/crates/vp_cli_snapshots/tests/cli_snapshots/fixtures/migration_eslint_rerun_dual_config/snapshots/migration_eslint_rerun_dual_config.md @@ -1,6 +1,6 @@ # migration_eslint_rerun_dual_config -## `vp migrate --no-interactive` +## `vp migrate --full --no-interactive` should detect vite-plus + eslint and auto-migrate eslint @@ -12,8 +12,9 @@ VITE+ - The Unified Toolchain for the Web • Dependencies: vite-plus latest → vite → +• 5 config updates applied +• ESLint rules migrated to Oxlint • Package manager settings configured -• Skipped editor, hooks, and lint setup. Run `vp migrate --full` to apply them. ``` ## `vpt print-file package.json` @@ -24,10 +25,10 @@ check eslint removed and scripts rewritten { "name": "migration-eslint-rerun-dual-config", "scripts": { - "lint": "eslint ." + "lint": "vp lint .", + "prepare": "vp config" }, "devDependencies": { - "eslint": "^9.0.0", "vite-plus": "catalog:" } } @@ -37,31 +38,55 @@ check eslint removed and scripts rewritten check flat config is removed -**Exit code:** 1 - ``` -eslint.config.mjs: file -stat-file assertion failed +eslint.config.mjs: missing ``` ## `vpt stat-file .eslintrc --assert-not file` check legacy config is also removed -**Exit code:** 1 - ``` -.eslintrc: file -stat-file assertion failed +.eslintrc: missing ``` ## `vpt print-file vite.config.ts` check oxlint config merged into vite.config.ts -**Exit code:** 1 - ``` -vite.config.ts: not found -missing file +import { defineConfig } from 'vite-plus'; + +export default defineConfig({ + staged: { + "*": "vp check --fix" + }, + lint: { + "plugins": [ + "oxc", + "typescript", + "unicorn" + ], + "categories": { + "correctness": "warn" + }, + "env": { + "builtin": true + }, + "rules": { + "no-unused-vars": "error", + "vite-plus/prefer-vite-plus-imports": "error" + }, + "options": { + "typeAware": true, + "typeCheck": true + }, + "jsPlugins": [ + { + "name": "vite-plus", + "specifier": "vite-plus/oxlint-plugin" + } + ] + }, +}); ``` diff --git a/crates/vp_cli_snapshots/tests/cli_snapshots/fixtures/migration_eslint_rerun_mjs/snapshots.toml b/crates/vp_cli_snapshots/tests/cli_snapshots/fixtures/migration_eslint_rerun_mjs/snapshots.toml index 8a3ee720c6..31b4c1c0be 100644 --- a/crates/vp_cli_snapshots/tests/cli_snapshots/fixtures/migration_eslint_rerun_mjs/snapshots.toml +++ b/crates/vp_cli_snapshots/tests/cli_snapshots/fixtures/migration_eslint_rerun_mjs/snapshots.toml @@ -3,7 +3,7 @@ name = "migration_eslint_rerun_mjs" vp = "global" skip-platforms = [{ os = "linux", libc = "musl" }] steps = [ - { argv = ["vp", "migrate", "--no-interactive"], comment = "should detect vite-plus + eslint and auto-migrate eslint", continue-on-failure = true }, + { argv = ["vp", "migrate", "--full", "--no-interactive"], comment = "should detect vite-plus + eslint and auto-migrate eslint", continue-on-failure = true }, { argv = ["vpt", "print-file", "package.json"], comment = "check eslint removed from devDependencies and scripts rewritten", continue-on-failure = true }, { argv = ["vpt", "stat-file", "eslint.config.mjs", "--assert-not", "file"], comment = "check eslint config is removed", continue-on-failure = true }, { argv = ["vpt", "print-file", "vite.config.mjs"], comment = "check oxlint config merged into existing vite.config.mjs (not creating vite.config.ts)", continue-on-failure = true }, diff --git a/crates/vp_cli_snapshots/tests/cli_snapshots/fixtures/migration_eslint_rerun_mjs/snapshots/migration_eslint_rerun_mjs.md b/crates/vp_cli_snapshots/tests/cli_snapshots/fixtures/migration_eslint_rerun_mjs/snapshots/migration_eslint_rerun_mjs.md index 6410700acb..bd73c10daa 100644 --- a/crates/vp_cli_snapshots/tests/cli_snapshots/fixtures/migration_eslint_rerun_mjs/snapshots/migration_eslint_rerun_mjs.md +++ b/crates/vp_cli_snapshots/tests/cli_snapshots/fixtures/migration_eslint_rerun_mjs/snapshots/migration_eslint_rerun_mjs.md @@ -1,6 +1,6 @@ # migration_eslint_rerun_mjs -## `vp migrate --no-interactive` +## `vp migrate --full --no-interactive` should detect vite-plus + eslint and auto-migrate eslint @@ -12,8 +12,9 @@ VITE+ - The Unified Toolchain for the Web • Dependencies: vite-plus latest → vite → +• 3 config updates applied +• ESLint rules migrated to Oxlint • Package manager settings configured -• Skipped editor, hooks, and lint setup. Run `vp migrate --full` to apply them. ``` ## `vpt print-file package.json` @@ -24,10 +25,10 @@ check eslint removed from devDependencies and scripts rewritten { "name": "migration-eslint-rerun-mjs", "scripts": { - "lint": "eslint ." + "lint": "vp lint .", + "prepare": "vp config" }, "devDependencies": { - "eslint": "^9.0.0", "vite-plus": "catalog:" } } @@ -37,11 +38,8 @@ check eslint removed from devDependencies and scripts rewritten check eslint config is removed -**Exit code:** 1 - ``` -eslint.config.mjs: file -stat-file assertion failed +eslint.config.mjs: missing ``` ## `vpt print-file vite.config.mjs` @@ -51,5 +49,36 @@ check oxlint config merged into existing vite.config.mjs (not creating vite.conf ``` import { defineConfig } from 'vite-plus'; -export default defineConfig({}); +export default defineConfig({ + staged: { + "*": "vp check --fix" + }, + lint: { + "plugins": [ + "oxc", + "typescript", + "unicorn" + ], + "categories": { + "correctness": "warn" + }, + "env": { + "builtin": true + }, + "rules": { + "no-unused-vars": "error", + "vite-plus/prefer-vite-plus-imports": "error" + }, + "options": { + "typeAware": true, + "typeCheck": true + }, + "jsPlugins": [ + { + "name": "vite-plus", + "specifier": "vite-plus/oxlint-plugin" + } + ] + }, +}); ``` diff --git a/crates/vp_cli_snapshots/tests/cli_snapshots/fixtures/migration_prettier_rerun/snapshots.toml b/crates/vp_cli_snapshots/tests/cli_snapshots/fixtures/migration_prettier_rerun/snapshots.toml index 4a2229e8ed..c23e8db430 100644 --- a/crates/vp_cli_snapshots/tests/cli_snapshots/fixtures/migration_prettier_rerun/snapshots.toml +++ b/crates/vp_cli_snapshots/tests/cli_snapshots/fixtures/migration_prettier_rerun/snapshots.toml @@ -3,7 +3,7 @@ name = "migration_prettier_rerun" vp = "global" skip-platforms = [{ os = "linux", libc = "musl" }] steps = [ - { argv = ["vp", "migrate", "--no-interactive"], comment = "should detect vite-plus + prettier and auto-migrate prettier", continue-on-failure = true }, + { argv = ["vp", "migrate", "--full", "--no-interactive"], comment = "should detect vite-plus + prettier and auto-migrate prettier", continue-on-failure = true }, { argv = ["vpt", "print-file", "package.json"], comment = "check prettier removed from devDependencies and scripts rewritten", continue-on-failure = true }, { argv = ["vpt", "stat-file", ".prettierrc.json", "--assert-not", "file"], comment = "check prettier config is removed", continue-on-failure = true }, { argv = ["vpt", "print-file", "vite.config.ts"], comment = "check oxfmt config merged into vite.config.ts", continue-on-failure = true }, diff --git a/crates/vp_cli_snapshots/tests/cli_snapshots/fixtures/migration_prettier_rerun/snapshots/migration_prettier_rerun.md b/crates/vp_cli_snapshots/tests/cli_snapshots/fixtures/migration_prettier_rerun/snapshots/migration_prettier_rerun.md index f0e4fd1895..74a1b4d6d7 100644 --- a/crates/vp_cli_snapshots/tests/cli_snapshots/fixtures/migration_prettier_rerun/snapshots/migration_prettier_rerun.md +++ b/crates/vp_cli_snapshots/tests/cli_snapshots/fixtures/migration_prettier_rerun/snapshots/migration_prettier_rerun.md @@ -1,19 +1,21 @@ # migration_prettier_rerun -## `vp migrate --no-interactive` +## `vp migrate --full --no-interactive` should detect vite-plus + prettier and auto-migrate prettier ``` VITE+ - The Unified Toolchain for the Web +● Prettier configuration detected. Auto-migrating to Oxfmt... ◇ Updated . to Vite+ • Node pnpm • Dependencies: vite-plus latest → vite → +• 2 config updates applied +• Prettier migrated to Oxfmt • Package manager settings configured -• Skipped editor, hooks, and lint setup. Run `vp migrate --full` to apply them. ``` ## `vpt print-file package.json` @@ -24,10 +26,10 @@ check prettier removed from devDependencies and scripts rewritten { "name": "migration-prettier-rerun", "scripts": { - "format": "prettier --write ." + "format": "vp fmt .", + "prepare": "vp config" }, "devDependencies": { - "prettier": "^3.0.0", "vite-plus": "catalog:" } } @@ -37,20 +39,27 @@ check prettier removed from devDependencies and scripts rewritten check prettier config is removed -**Exit code:** 1 - ``` -.prettierrc.json: file -stat-file assertion failed +.prettierrc.json: missing ``` ## `vpt print-file vite.config.ts` check oxfmt config merged into vite.config.ts -**Exit code:** 1 - ``` -vite.config.ts: not found -missing file +import { defineConfig } from "vite-plus"; + +export default defineConfig({ + staged: { + "*": "vp check --fix" + }, + fmt: { + semi: true, + singleQuote: true, + printWidth: 80, + sortPackageJson: false, + ignorePatterns: [], + }, +}); ```