From f4ff52c53b540e0916e9f166910374a6fd20bbd2 Mon Sep 17 00:00:00 2001 From: chb Date: Tue, 10 Nov 2026 15:42:00 +0900 Subject: [PATCH 1/5] feat(check): support --fix-dangerously Support dangerous lint fixes and suggestions in vp check. Add CLI snapshot coverage and update the documentation. --- .../check_fix_dangerously/package.json | 4 ++ .../check_fix_dangerously/snapshots.toml | 56 +++++++++++++++++++ .../snapshots/check_fix_dangerously.md | 49 ++++++++++++++++ .../check_fix_dangerously_config_no_lint.md | 24 ++++++++ ...check_fix_dangerously_continue_on_error.md | 53 ++++++++++++++++++ .../snapshots/check_fix_dangerously_no_fmt.md | 33 +++++++++++ .../check_fix_dangerously_no_lint.md | 46 +++++++++++++++ .../check_fix_dangerously_with_fix.md | 26 +++++++++ .../check_fix_dangerously/src/index.js | 5 ++ .../check_fix_dangerously/vite.config.ts | 9 +++ .../snapshots.toml | 8 +++ ...check_fix_dangerously_no_lint_typecheck.md | 15 +++++ .../snapshots.toml | 7 +++ ..._fix_dangerously_no_lint_typecheck_fail.md | 18 ++++++ .../snapshots/command_check_help.md | 3 + docs/guide/check.md | 9 +++ packages/cli/binding/src/check/mod.rs | 6 +- packages/cli/binding/src/cli/mod.rs | 2 + packages/cli/binding/src/cli/types.rs | 3 + packages/cli/src/help.ts | 5 ++ packages/core/package.json | 4 +- 21 files changed, 381 insertions(+), 4 deletions(-) create mode 100644 crates/vp_cli_snapshots/tests/cli_snapshots/fixtures/check_fix_dangerously/package.json create mode 100644 crates/vp_cli_snapshots/tests/cli_snapshots/fixtures/check_fix_dangerously/snapshots.toml create mode 100644 crates/vp_cli_snapshots/tests/cli_snapshots/fixtures/check_fix_dangerously/snapshots/check_fix_dangerously.md create mode 100644 crates/vp_cli_snapshots/tests/cli_snapshots/fixtures/check_fix_dangerously/snapshots/check_fix_dangerously_config_no_lint.md create mode 100644 crates/vp_cli_snapshots/tests/cli_snapshots/fixtures/check_fix_dangerously/snapshots/check_fix_dangerously_continue_on_error.md create mode 100644 crates/vp_cli_snapshots/tests/cli_snapshots/fixtures/check_fix_dangerously/snapshots/check_fix_dangerously_no_fmt.md create mode 100644 crates/vp_cli_snapshots/tests/cli_snapshots/fixtures/check_fix_dangerously/snapshots/check_fix_dangerously_no_lint.md create mode 100644 crates/vp_cli_snapshots/tests/cli_snapshots/fixtures/check_fix_dangerously/snapshots/check_fix_dangerously_with_fix.md create mode 100644 crates/vp_cli_snapshots/tests/cli_snapshots/fixtures/check_fix_dangerously/src/index.js create mode 100644 crates/vp_cli_snapshots/tests/cli_snapshots/fixtures/check_fix_dangerously/vite.config.ts create mode 100644 crates/vp_cli_snapshots/tests/cli_snapshots/fixtures/check_fix_no_lint_typecheck/snapshots/check_fix_dangerously_no_lint_typecheck.md create mode 100644 crates/vp_cli_snapshots/tests/cli_snapshots/fixtures/check_fix_no_lint_typecheck_fail/snapshots/check_fix_dangerously_no_lint_typecheck_fail.md diff --git a/crates/vp_cli_snapshots/tests/cli_snapshots/fixtures/check_fix_dangerously/package.json b/crates/vp_cli_snapshots/tests/cli_snapshots/fixtures/check_fix_dangerously/package.json new file mode 100644 index 0000000000..25bf99f98c --- /dev/null +++ b/crates/vp_cli_snapshots/tests/cli_snapshots/fixtures/check_fix_dangerously/package.json @@ -0,0 +1,4 @@ +{ + "name": "check-fix-dangerously", + "private": true +} diff --git a/crates/vp_cli_snapshots/tests/cli_snapshots/fixtures/check_fix_dangerously/snapshots.toml b/crates/vp_cli_snapshots/tests/cli_snapshots/fixtures/check_fix_dangerously/snapshots.toml new file mode 100644 index 0000000000..f40fedbf61 --- /dev/null +++ b/crates/vp_cli_snapshots/tests/cli_snapshots/fixtures/check_fix_dangerously/snapshots.toml @@ -0,0 +1,56 @@ +[[case]] +name = "check_fix_dangerously" +vp = "local" +steps = [ + { argv = ["vp", "check", "--fix"], comment = "safe fixes leave the unused variable diagnostic", continue-on-failure = true }, + { argv = ["vp", "check", "--fix-dangerously"], comment = "dangerous fixes do not require --fix" }, + ["vpt", "print-file", "src/index.js"], + ["vp", "check"], +] + +[[case]] +name = "check_fix_dangerously_with_fix" +vp = "local" +steps = [ + ["vp", "check", "--fix", "--fix-dangerously"], + ["vpt", "print-file", "src/index.js"], + ["vp", "check"], +] + +[[case]] +name = "check_fix_dangerously_no_fmt" +vp = "local" +steps = [ + ["vp", "check", "--fix-dangerously", "--no-fmt", "src/index.js"], + ["vpt", "print-file", "src/index.js"], + { argv = ["vp", "fmt", "--check", "src/index.js"], comment = "formatting remains skipped after lint fixes", continue-on-failure = true }, +] + +[[case]] +name = "check_fix_dangerously_no_lint" +vp = "local" +steps = [ + ["vp", "check", "--fix-dangerously", "--no-lint", "src/index.js"], + ["vpt", "print-file", "src/index.js"], + { argv = ["vp", "check", "--no-fmt", "src/index.js"], comment = "lint was skipped, so the unused variable remains", continue-on-failure = true }, +] + +[[case]] +name = "check_fix_dangerously_continue_on_error" +vp = "local" +steps = [ + ["vpt", "write-file", "src/error.js", "eval('value');\n"], + ["vpt", "write-file", "vite.config.ts", "export default { lint: { categories: { correctness: 'off' }, rules: { 'no-unused-vars': 'error', curly: 'error', 'no-eval': 'error' } } };\n"], + { argv = ["vp", "check", "--fix-dangerously", "--continue-on-error"], comment = "remaining lint errors preserve a nonzero exit while the final format pass runs", continue-on-failure = true }, + ["vpt", "print-file", "src/index.js"], + ["vp", "fmt", "--check", "src/index.js"], +] + +[[case]] +name = "check_fix_dangerously_config_no_lint" +vp = "local" +steps = [ + ["vpt", "write-file", "vite.config.ts", "export default { check: { lint: false }, lint: { rules: { 'no-unused-vars': 'error' } } };\n"], + ["vp", "check", "--fix-dangerously", "src/index.js"], + ["vpt", "print-file", "src/index.js"], +] diff --git a/crates/vp_cli_snapshots/tests/cli_snapshots/fixtures/check_fix_dangerously/snapshots/check_fix_dangerously.md b/crates/vp_cli_snapshots/tests/cli_snapshots/fixtures/check_fix_dangerously/snapshots/check_fix_dangerously.md new file mode 100644 index 0000000000..4f5c0967e8 --- /dev/null +++ b/crates/vp_cli_snapshots/tests/cli_snapshots/fixtures/check_fix_dangerously/snapshots/check_fix_dangerously.md @@ -0,0 +1,49 @@ +# check_fix_dangerously + +## `vp check --fix` + +safe fixes leave the unused variable diagnostic + +**Exit code:** 1 + +``` +error: Lint issues found +× eslint(no-unused-vars): Variable 'unused' is declared but never used. Unused variables should start with a '_'. + ╭─[src/index.js:1:7] + 1 │ const unused = 1; + · ───┬── + · ╰── 'unused' is declared here + 2 │ export function greet(enabled) { + ╰──── + help: Consider removing this declaration. + +Found 1 error and 0 warnings in 2 files (, threads) +pass: Formatting completed for checked files () +``` + +## `vp check --fix-dangerously` + +dangerous fixes do not require --fix + +``` +pass: Formatting completed for checked files () +pass: Found no warnings or lint errors in 2 files (, threads) +``` + +## `vpt print-file src/index.js` + +``` +export function greet(enabled) { + if (enabled) { + return "hello"; + } + return "world"; +} +``` + +## `vp check` + +``` +pass: All 3 files are correctly formatted (, threads) +pass: Found no warnings or lint errors in 2 files (, threads) +``` diff --git a/crates/vp_cli_snapshots/tests/cli_snapshots/fixtures/check_fix_dangerously/snapshots/check_fix_dangerously_config_no_lint.md b/crates/vp_cli_snapshots/tests/cli_snapshots/fixtures/check_fix_dangerously/snapshots/check_fix_dangerously_config_no_lint.md new file mode 100644 index 0000000000..b0f28d306f --- /dev/null +++ b/crates/vp_cli_snapshots/tests/cli_snapshots/fixtures/check_fix_dangerously/snapshots/check_fix_dangerously_config_no_lint.md @@ -0,0 +1,24 @@ +# check_fix_dangerously_config_no_lint + +## `vpt write-file vite.config.ts 'export default { check: { lint: false }, lint: { rules: { '\''no-unused-vars'\'': '\''error'\'' } } }; +'` + +``` +``` + +## `vp check --fix-dangerously src/index.js` + +``` +note: Lint skipped (check.lint: false in vite.config.ts) +pass: Formatting completed for checked files () +``` + +## `vpt print-file src/index.js` + +``` +const unused = 1; +export function greet(enabled) { + if (enabled) return "hello"; + return "world"; +} +``` diff --git a/crates/vp_cli_snapshots/tests/cli_snapshots/fixtures/check_fix_dangerously/snapshots/check_fix_dangerously_continue_on_error.md b/crates/vp_cli_snapshots/tests/cli_snapshots/fixtures/check_fix_dangerously/snapshots/check_fix_dangerously_continue_on_error.md new file mode 100644 index 0000000000..b5ce751e67 --- /dev/null +++ b/crates/vp_cli_snapshots/tests/cli_snapshots/fixtures/check_fix_dangerously/snapshots/check_fix_dangerously_continue_on_error.md @@ -0,0 +1,53 @@ +# check_fix_dangerously_continue_on_error + +## `vpt write-file src/error.js 'eval('\''value'\''); +'` + +``` +``` + +## `vpt write-file vite.config.ts 'export default { lint: { categories: { correctness: '\''off'\'' }, rules: { '\''no-unused-vars'\'': '\''error'\'', curly: '\''error'\'', '\''no-eval'\'': '\''error'\'' } } }; +'` + +``` +``` + +## `vp check --fix-dangerously --continue-on-error` + +remaining lint errors preserve a nonzero exit while the final format pass runs + +**Exit code:** 1 + +``` +error: Lint issues found +× eslint(no-eval): eval can be harmful. + ╭─[src/error.js:1:1] + 1 │ eval("value"); + · ──── + ╰──── + help: Avoid eval(). For JSON parsing use JSON.parse(); for dynamic property access use bracket notation (obj[key]); for other cases refactor to avoid evaluating strings as code. + +Found 1 error and 0 warnings in 3 files (, threads) +pass: Formatting completed for checked files () +``` + +## `vpt print-file src/index.js` + +``` +export function greet(enabled) { + if (enabled) { + return "hello"; + } + return "world"; +} +``` + +## `vp fmt --check src/index.js` + +``` +Checking formatting... + +All matched files use the correct format. +Finished in on 1 files using threads. +No config found, using defaults. Please add a config file or try `vp fmt --init` if needed. +``` diff --git a/crates/vp_cli_snapshots/tests/cli_snapshots/fixtures/check_fix_dangerously/snapshots/check_fix_dangerously_no_fmt.md b/crates/vp_cli_snapshots/tests/cli_snapshots/fixtures/check_fix_dangerously/snapshots/check_fix_dangerously_no_fmt.md new file mode 100644 index 0000000000..27619cd971 --- /dev/null +++ b/crates/vp_cli_snapshots/tests/cli_snapshots/fixtures/check_fix_dangerously/snapshots/check_fix_dangerously_no_fmt.md @@ -0,0 +1,33 @@ +# check_fix_dangerously_no_fmt + +## `vp check --fix-dangerously --no-fmt src/index.js` + +``` +pass: Found no warnings or lint errors in 1 file (, threads) +``` + +## `vpt print-file src/index.js` + +``` + +export function greet(enabled) { + if (enabled) {return "hello";} + return "world"; +} +``` + +## `vp fmt --check src/index.js` + +formatting remains skipped after lint fixes + +**Exit code:** 1 + +``` +Checking formatting... + +src/index.js () + +Format issues found in above 1 files. Run without `--check` to fix. +Finished in on 1 files using threads. +No config found, using defaults. Please add a config file or try `vp fmt --init` if needed. +``` diff --git a/crates/vp_cli_snapshots/tests/cli_snapshots/fixtures/check_fix_dangerously/snapshots/check_fix_dangerously_no_lint.md b/crates/vp_cli_snapshots/tests/cli_snapshots/fixtures/check_fix_dangerously/snapshots/check_fix_dangerously_no_lint.md new file mode 100644 index 0000000000..a828e3cf6b --- /dev/null +++ b/crates/vp_cli_snapshots/tests/cli_snapshots/fixtures/check_fix_dangerously/snapshots/check_fix_dangerously_no_lint.md @@ -0,0 +1,46 @@ +# check_fix_dangerously_no_lint + +## `vp check --fix-dangerously --no-lint src/index.js` + +``` +pass: Formatting completed for checked files () +``` + +## `vpt print-file src/index.js` + +``` +const unused = 1; +export function greet(enabled) { + if (enabled) return "hello"; + return "world"; +} +``` + +## `vp check --no-fmt src/index.js` + +lint was skipped, so the unused variable remains + +**Exit code:** 1 + +``` +error: Lint issues found +× eslint(no-unused-vars): Variable 'unused' is declared but never used. Unused variables should start with a '_'. + ╭─[src/index.js:1:7] + 1 │ const unused = 1; + · ───┬── + · ╰── 'unused' is declared here + 2 │ export function greet(enabled) { + ╰──── + help: Consider removing this declaration. + + × eslint(curly): Expected { after 'if' condition. + ╭─[src/index.js:3:16] + 2 │ export function greet(enabled) { + 3 │ if (enabled) return "hello"; + · ─────────────── + 4 │ return "world"; + ╰──── + help: Replace `return "hello";` with `{return "hello";}`. + +Found 2 errors and 0 warnings in 1 file (, threads) +``` diff --git a/crates/vp_cli_snapshots/tests/cli_snapshots/fixtures/check_fix_dangerously/snapshots/check_fix_dangerously_with_fix.md b/crates/vp_cli_snapshots/tests/cli_snapshots/fixtures/check_fix_dangerously/snapshots/check_fix_dangerously_with_fix.md new file mode 100644 index 0000000000..4c7aa75a28 --- /dev/null +++ b/crates/vp_cli_snapshots/tests/cli_snapshots/fixtures/check_fix_dangerously/snapshots/check_fix_dangerously_with_fix.md @@ -0,0 +1,26 @@ +# check_fix_dangerously_with_fix + +## `vp check --fix --fix-dangerously` + +``` +pass: Formatting completed for checked files () +pass: Found no warnings or lint errors in 2 files (, threads) +``` + +## `vpt print-file src/index.js` + +``` +export function greet(enabled) { + if (enabled) { + return "hello"; + } + return "world"; +} +``` + +## `vp check` + +``` +pass: All 3 files are correctly formatted (, threads) +pass: Found no warnings or lint errors in 2 files (, threads) +``` diff --git a/crates/vp_cli_snapshots/tests/cli_snapshots/fixtures/check_fix_dangerously/src/index.js b/crates/vp_cli_snapshots/tests/cli_snapshots/fixtures/check_fix_dangerously/src/index.js new file mode 100644 index 0000000000..b5622a9682 --- /dev/null +++ b/crates/vp_cli_snapshots/tests/cli_snapshots/fixtures/check_fix_dangerously/src/index.js @@ -0,0 +1,5 @@ +const unused = 1; +export function greet(enabled) { + if (enabled) return "hello"; + return "world"; +} diff --git a/crates/vp_cli_snapshots/tests/cli_snapshots/fixtures/check_fix_dangerously/vite.config.ts b/crates/vp_cli_snapshots/tests/cli_snapshots/fixtures/check_fix_dangerously/vite.config.ts new file mode 100644 index 0000000000..5f8f0ddb5c --- /dev/null +++ b/crates/vp_cli_snapshots/tests/cli_snapshots/fixtures/check_fix_dangerously/vite.config.ts @@ -0,0 +1,9 @@ +export default { + lint: { + categories: { correctness: "off" }, + rules: { + "no-unused-vars": "error", + curly: "error", + }, + }, +}; diff --git a/crates/vp_cli_snapshots/tests/cli_snapshots/fixtures/check_fix_no_lint_typecheck/snapshots.toml b/crates/vp_cli_snapshots/tests/cli_snapshots/fixtures/check_fix_no_lint_typecheck/snapshots.toml index b865fde2c4..b106faa243 100644 --- a/crates/vp_cli_snapshots/tests/cli_snapshots/fixtures/check_fix_no_lint_typecheck/snapshots.toml +++ b/crates/vp_cli_snapshots/tests/cli_snapshots/fixtures/check_fix_no_lint_typecheck/snapshots.toml @@ -4,3 +4,11 @@ vp = "local" steps = [ { argv = ["vp", "check", "--fix", "--no-lint"], continue-on-failure = true }, ] + +[[case]] +name = "check_fix_dangerously_no_lint_typecheck" +vp = "local" +steps = [ + ["vp", "check", "--fix-dangerously", "--no-lint"], + ["vpt", "print-file", "src/index.ts"], +] diff --git a/crates/vp_cli_snapshots/tests/cli_snapshots/fixtures/check_fix_no_lint_typecheck/snapshots/check_fix_dangerously_no_lint_typecheck.md b/crates/vp_cli_snapshots/tests/cli_snapshots/fixtures/check_fix_no_lint_typecheck/snapshots/check_fix_dangerously_no_lint_typecheck.md new file mode 100644 index 0000000000..1ae5e68265 --- /dev/null +++ b/crates/vp_cli_snapshots/tests/cli_snapshots/fixtures/check_fix_no_lint_typecheck/snapshots/check_fix_dangerously_no_lint_typecheck.md @@ -0,0 +1,15 @@ +# check_fix_dangerously_no_lint_typecheck + +## `vp check --fix-dangerously --no-lint` + +``` +pass: Formatting completed for checked files () +pass: Found no type errors in 2 files (, threads) +``` + +## `vpt print-file src/index.ts` + +``` +const value: number = 42; +export { value }; +``` diff --git a/crates/vp_cli_snapshots/tests/cli_snapshots/fixtures/check_fix_no_lint_typecheck_fail/snapshots.toml b/crates/vp_cli_snapshots/tests/cli_snapshots/fixtures/check_fix_no_lint_typecheck_fail/snapshots.toml index 76ce12453c..93825df460 100644 --- a/crates/vp_cli_snapshots/tests/cli_snapshots/fixtures/check_fix_no_lint_typecheck_fail/snapshots.toml +++ b/crates/vp_cli_snapshots/tests/cli_snapshots/fixtures/check_fix_no_lint_typecheck_fail/snapshots.toml @@ -4,3 +4,10 @@ vp = "local" steps = [ { argv = ["vp", "check", "--fix", "--no-lint"], continue-on-failure = true }, ] + +[[case]] +name = "check_fix_dangerously_no_lint_typecheck_fail" +vp = "local" +steps = [ + { argv = ["vp", "check", "--fix-dangerously", "--no-lint"], continue-on-failure = true }, +] diff --git a/crates/vp_cli_snapshots/tests/cli_snapshots/fixtures/check_fix_no_lint_typecheck_fail/snapshots/check_fix_dangerously_no_lint_typecheck_fail.md b/crates/vp_cli_snapshots/tests/cli_snapshots/fixtures/check_fix_no_lint_typecheck_fail/snapshots/check_fix_dangerously_no_lint_typecheck_fail.md new file mode 100644 index 0000000000..c3cbe2c187 --- /dev/null +++ b/crates/vp_cli_snapshots/tests/cli_snapshots/fixtures/check_fix_no_lint_typecheck_fail/snapshots/check_fix_dangerously_no_lint_typecheck_fail.md @@ -0,0 +1,18 @@ +# check_fix_dangerously_no_lint_typecheck_fail + +## `vp check --fix-dangerously --no-lint` + +**Exit code:** 1 + +``` +error: Type errors found +× typescript(TS2322): Type 'string' is not assignable to type 'number'. + ╭─[src/index.ts:1:7] + 1 │ const value: number = "not a number"; + · ───── + 2 │ export { value }; + ╰──── + +Found 1 error and 0 warnings in 2 files (, threads) +pass: Formatting completed for checked files () +``` diff --git a/crates/vp_cli_snapshots/tests/cli_snapshots/fixtures/command_check_help/snapshots/command_check_help.md b/crates/vp_cli_snapshots/tests/cli_snapshots/fixtures/command_check_help/snapshots/command_check_help.md index 0f914043c6..9aaa4e3ce4 100644 --- a/crates/vp_cli_snapshots/tests/cli_snapshots/fixtures/command_check_help/snapshots/command_check_help.md +++ b/crates/vp_cli_snapshots/tests/cli_snapshots/fixtures/command_check_help/snapshots/command_check_help.md @@ -14,6 +14,7 @@ Arguments: Options: --fix Auto-fix format and lint issues + --fix-dangerously Auto-fix format and lint issues, including dangerous fixes and suggestions --continue-on-error Run remaining checks even if an earlier check fails --quiet Disable reporting on warnings, only errors are reported --deny-warnings Treat lint warnings as errors @@ -45,6 +46,7 @@ Arguments: Options: --fix Auto-fix format and lint issues + --fix-dangerously Auto-fix format and lint issues, including dangerous fixes and suggestions --continue-on-error Run remaining checks even if an earlier check fails --quiet Disable reporting on warnings, only errors are reported --deny-warnings Treat lint warnings as errors @@ -76,6 +78,7 @@ Arguments: Options: --fix Auto-fix format and lint issues + --fix-dangerously Auto-fix format and lint issues, including dangerous fixes and suggestions --continue-on-error Run remaining checks even if an earlier check fails --quiet Disable reporting on warnings, only errors are reported --deny-warnings Treat lint warnings as errors diff --git a/docs/guide/check.md b/docs/guide/check.md index a80ae27496..02ea53d077 100644 --- a/docs/guide/check.md +++ b/docs/guide/check.md @@ -15,6 +15,7 @@ We recommend turning both `typeAware` and `typeCheck` on so `vp check` becomes t ```bash vp check vp check --fix # Format and run autofixers. +vp check --fix-dangerously # Format and apply lint fixes, including dangerous fixes and suggestions. vp check --continue-on-error # Report all enabled checks, even if formatting fails. vp check --quiet # Hide lint warnings; still report and fail on errors. vp check --deny-warnings # Treat lint warnings as errors. @@ -25,6 +26,14 @@ vp check --no-fmt --no-lint # Type-check only (requires both `typeAware` and `ty If formatting fails, `vp check` stops before lint and type checks run. To fix formatting and apply available lint fixes, run `vp check --fix`. This command changes files. To skip formatting and run the remaining enabled checks, run `vp check --no-fmt`. +Use `vp check --fix-dangerously` to also apply dangerous lint fixes and suggestions. +This option enables formatting fixes without requiring `--fix`. Dangerous lint fixes +may change program behavior, so review the changes before committing them. When both +flags are passed, `--fix-dangerously` takes precedence for lint fixes. +Like `--fix`, it supports `--no-fmt` and `--continue-on-error`; lint fixes are skipped +when lint rules are disabled with `--no-lint` or `check.lint: false`. Type diagnostics +are not automatically fixed. + Use `vp check --continue-on-error` to run all enabled checks and report formatting, lint, and type errors in one invocation without modifying files. Type checks still require the existing `lint.options.typeAware` and `lint.options.typeCheck` settings. diff --git a/packages/cli/binding/src/check/mod.rs b/packages/cli/binding/src/check/mod.rs index 327d26a649..29d28786db 100644 --- a/packages/cli/binding/src/check/mod.rs +++ b/packages/cli/binding/src/check/mod.rs @@ -22,6 +22,7 @@ pub(crate) async fn execute_check( resolver: &SubcommandResolver, continue_on_error: bool, fix: bool, + fix_dangerously: bool, quiet: bool, deny_warnings: bool, no_fmt_flag: bool, @@ -31,6 +32,7 @@ pub(crate) async fn execute_check( envs: &Arc, cwd: &AbsolutePathBuf, ) -> Result { + let fix = fix || fix_dangerously; let mut status = ExitStatus::SUCCESS; let mut first_failure = None; let has_paths = !paths.is_empty(); @@ -175,10 +177,10 @@ pub(crate) async fn execute_check( if run_lint_phase { let lint_message_kind = LintMessageKind::from_flags(lint_enabled, type_check_enabled); let mut args = config_args(resolved_vite_config.lint.is_some()); - // oxlint cannot auto-fix type diagnostics, so `--fix` is dropped on the + // oxlint cannot auto-fix type diagnostics, so fix flags are dropped on the // type-check-only path. if fix && lint_enabled { - args.push("--fix".to_string()); + args.push(if fix_dangerously { "--fix-dangerously" } else { "--fix" }.to_string()); } if quiet { args.push("--quiet".to_string()); diff --git a/packages/cli/binding/src/cli/mod.rs b/packages/cli/binding/src/cli/mod.rs index 9bed3e73b3..d0191676dc 100644 --- a/packages/cli/binding/src/cli/mod.rs +++ b/packages/cli/binding/src/cli/mod.rs @@ -99,6 +99,7 @@ async fn execute_direct_subcommand( SynthesizableSubcommand::Check { continue_on_error, fix, + fix_dangerously, quiet, deny_warnings, no_fmt, @@ -110,6 +111,7 @@ async fn execute_direct_subcommand( &resolver, continue_on_error, fix, + fix_dangerously, quiet, deny_warnings, no_fmt, diff --git a/packages/cli/binding/src/cli/types.rs b/packages/cli/binding/src/cli/types.rs index 9fb55641c4..e990d323b3 100644 --- a/packages/cli/binding/src/cli/types.rs +++ b/packages/cli/binding/src/cli/types.rs @@ -89,6 +89,9 @@ pub enum SynthesizableSubcommand { /// Auto-fix format and lint issues #[arg(long)] fix: bool, + /// Auto-fix format and lint issues, including dangerous fixes and suggestions + #[arg(long)] + fix_dangerously: bool, /// Disable reporting on warnings, only errors are reported #[arg(long)] quiet: bool, diff --git a/packages/cli/src/help.ts b/packages/cli/src/help.ts index d01a30e4d5..91966f5e21 100644 --- a/packages/cli/src/help.ts +++ b/packages/cli/src/help.ts @@ -829,6 +829,11 @@ const commandHelpDocs = { title: 'Options', rows: [ { label: '--fix', description: 'Auto-fix format and lint issues' }, + { + label: '--fix-dangerously', + description: + 'Auto-fix format and lint issues, including dangerous fixes and suggestions', + }, { label: '--continue-on-error', description: 'Run remaining checks even if an earlier check fails', diff --git a/packages/core/package.json b/packages/core/package.json index 2bb0583d8d..db5f1344d4 100644 --- a/packages/core/package.json +++ b/packages/core/package.json @@ -239,8 +239,8 @@ "node": "^20.19.0 || ^22.18.0 || >=24.11.0" }, "bundledVersions": { - "vite": "8.3.7", - "rolldown": "1.2.18", + "vite": "8.3.5", + "rolldown": "1.2.16", "tsdown": "0.23.4" } } From 164a7d59b39cecb58bda6485448a9fae7c15201c Mon Sep 17 00:00:00 2001 From: chb Date: Tue, 10 Nov 2026 15:52:40 +0900 Subject: [PATCH 2/5] fix(ci): restore bundled tool versions --- packages/core/package.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/core/package.json b/packages/core/package.json index db5f1344d4..2bb0583d8d 100644 --- a/packages/core/package.json +++ b/packages/core/package.json @@ -239,8 +239,8 @@ "node": "^20.19.0 || ^22.18.0 || >=24.11.0" }, "bundledVersions": { - "vite": "8.3.5", - "rolldown": "1.2.16", + "vite": "8.3.7", + "rolldown": "1.2.18", "tsdown": "0.23.4" } } From 0cf992489eee849ffdb164a9b05a09569dbbc46f Mon Sep 17 00:00:00 2001 From: chb Date: Tue, 10 Nov 2026 15:55:33 +0900 Subject: [PATCH 3/5] feat(check): support --fix-dangerously Support dangerous lint fixes and suggestions in vp check. Add CLI snapshot coverage and update the documentation. - fix(ci): restore bundled tool versions --- .../command_no_color/snapshots/command_no_color.global.md | 1 + .../command_no_color/snapshots/command_no_color.local.md | 1 + 2 files changed, 2 insertions(+) diff --git a/crates/vp_cli_snapshots/tests/cli_snapshots/fixtures/command_no_color/snapshots/command_no_color.global.md b/crates/vp_cli_snapshots/tests/cli_snapshots/fixtures/command_no_color/snapshots/command_no_color.global.md index 68a379d450..aceb41e7ec 100644 --- a/crates/vp_cli_snapshots/tests/cli_snapshots/fixtures/command_no_color/snapshots/command_no_color.global.md +++ b/crates/vp_cli_snapshots/tests/cli_snapshots/fixtures/command_no_color/snapshots/command_no_color.global.md @@ -14,6 +14,7 @@ Arguments: Options: --fix Auto-fix format and lint issues + --fix-dangerously Auto-fix format and lint issues, including dangerous fixes and suggestions --continue-on-error Run remaining checks even if an earlier check fails --quiet Disable reporting on warnings, only errors are reported --deny-warnings Treat lint warnings as errors diff --git a/crates/vp_cli_snapshots/tests/cli_snapshots/fixtures/command_no_color/snapshots/command_no_color.local.md b/crates/vp_cli_snapshots/tests/cli_snapshots/fixtures/command_no_color/snapshots/command_no_color.local.md index 39f4e287c7..3444020418 100644 --- a/crates/vp_cli_snapshots/tests/cli_snapshots/fixtures/command_no_color/snapshots/command_no_color.local.md +++ b/crates/vp_cli_snapshots/tests/cli_snapshots/fixtures/command_no_color/snapshots/command_no_color.local.md @@ -14,6 +14,7 @@ Arguments: Options: --fix Auto-fix format and lint issues + --fix-dangerously Auto-fix format and lint issues, including dangerous fixes and suggestions --continue-on-error Run remaining checks even if an earlier check fails --quiet Disable reporting on warnings, only errors are reported --deny-warnings Treat lint warnings as errors From 8ef324bea96bf5b9943d5399d1c94dfbf662c36d Mon Sep 17 00:00:00 2001 From: chb Date: Tue, 10 Nov 2026 16:15:07 +0900 Subject: [PATCH 4/5] feat(check): support --fix-dangerously Support dangerous lint fixes and suggestions in vp check. Add CLI snapshot coverage and update the documentation. - fix(ci): prepare Yarn before lockfile-only snapshot --- .../fixtures/install_package_options/snapshots.toml | 1 + .../snapshots/yarn_berry_lockfile_only.md | 5 +++++ 2 files changed, 6 insertions(+) diff --git a/crates/vp_cli_snapshots/tests/cli_snapshots/fixtures/install_package_options/snapshots.toml b/crates/vp_cli_snapshots/tests/cli_snapshots/fixtures/install_package_options/snapshots.toml index 63235a0d41..20bb469216 100644 --- a/crates/vp_cli_snapshots/tests/cli_snapshots/fixtures/install_package_options/snapshots.toml +++ b/crates/vp_cli_snapshots/tests/cli_snapshots/fixtures/install_package_options/snapshots.toml @@ -65,6 +65,7 @@ vp = "global" env = { YARN_ENABLE_TELEMETRY = "0", YARN_ENABLE_GLOBAL_CACHE = "0" } steps = [ { argv = ["vpt", "json-edit", "package.json", "packageManager", "yarn@4.10.3"], snapshot = false }, + { argv = ["yarn", "--version"], comment = "Prepare the pinned Yarn before checking install option output", snapshot = false }, { argv = ["vp", "install", "./dep", "--lockfile-only", "--ignore-scripts"], comment = "use update-lockfile rather than skip-build when both options are supplied" }, ["vpt", "stat-file", "yarn.lock", "--assert", "file"], ["vpt", "stat-file", "node_modules", "--assert", "missing"], diff --git a/crates/vp_cli_snapshots/tests/cli_snapshots/fixtures/install_package_options/snapshots/yarn_berry_lockfile_only.md b/crates/vp_cli_snapshots/tests/cli_snapshots/fixtures/install_package_options/snapshots/yarn_berry_lockfile_only.md index f1967c5d56..c3081599b0 100644 --- a/crates/vp_cli_snapshots/tests/cli_snapshots/fixtures/install_package_options/snapshots/yarn_berry_lockfile_only.md +++ b/crates/vp_cli_snapshots/tests/cli_snapshots/fixtures/install_package_options/snapshots/yarn_berry_lockfile_only.md @@ -3,6 +3,11 @@ ## `vpt json-edit package.json packageManager yarn@4.10.3` +## `yarn --version` + +Prepare the pinned Yarn before checking install option output + + ## `vp install ./dep --lockfile-only --ignore-scripts` use update-lockfile rather than skip-build when both options are supplied From 81ee5c75d97605bd10bf93f9f3d94b6acc2519dc Mon Sep 17 00:00:00 2001 From: chb Date: Tue, 10 Nov 2026 17:13:51 +0900 Subject: [PATCH 5/5] feat(check): support --fix-dangerously Support dangerous lint fixes and suggestions in vp check. Add CLI snapshot coverage and update the documentation. - fix(fixture): yarn fixture restore --- .../fixtures/install_package_options/snapshots.toml | 1 - .../snapshots/yarn_berry_lockfile_only.md | 5 ----- 2 files changed, 6 deletions(-) diff --git a/crates/vp_cli_snapshots/tests/cli_snapshots/fixtures/install_package_options/snapshots.toml b/crates/vp_cli_snapshots/tests/cli_snapshots/fixtures/install_package_options/snapshots.toml index 20bb469216..63235a0d41 100644 --- a/crates/vp_cli_snapshots/tests/cli_snapshots/fixtures/install_package_options/snapshots.toml +++ b/crates/vp_cli_snapshots/tests/cli_snapshots/fixtures/install_package_options/snapshots.toml @@ -65,7 +65,6 @@ vp = "global" env = { YARN_ENABLE_TELEMETRY = "0", YARN_ENABLE_GLOBAL_CACHE = "0" } steps = [ { argv = ["vpt", "json-edit", "package.json", "packageManager", "yarn@4.10.3"], snapshot = false }, - { argv = ["yarn", "--version"], comment = "Prepare the pinned Yarn before checking install option output", snapshot = false }, { argv = ["vp", "install", "./dep", "--lockfile-only", "--ignore-scripts"], comment = "use update-lockfile rather than skip-build when both options are supplied" }, ["vpt", "stat-file", "yarn.lock", "--assert", "file"], ["vpt", "stat-file", "node_modules", "--assert", "missing"], diff --git a/crates/vp_cli_snapshots/tests/cli_snapshots/fixtures/install_package_options/snapshots/yarn_berry_lockfile_only.md b/crates/vp_cli_snapshots/tests/cli_snapshots/fixtures/install_package_options/snapshots/yarn_berry_lockfile_only.md index c3081599b0..f1967c5d56 100644 --- a/crates/vp_cli_snapshots/tests/cli_snapshots/fixtures/install_package_options/snapshots/yarn_berry_lockfile_only.md +++ b/crates/vp_cli_snapshots/tests/cli_snapshots/fixtures/install_package_options/snapshots/yarn_berry_lockfile_only.md @@ -3,11 +3,6 @@ ## `vpt json-edit package.json packageManager yarn@4.10.3` -## `yarn --version` - -Prepare the pinned Yarn before checking install option output - - ## `vp install ./dep --lockfile-only --ignore-scripts` use update-lockfile rather than skip-build when both options are supplied