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,4 @@
{
"name": "check-fix-dangerously",
"private": true
}
Original file line number Diff line number Diff line change
@@ -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"],
]
Original file line number Diff line number Diff line change
@@ -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 (<duration>, <n> threads)
pass: Formatting completed for checked files (<duration>)
```

## `vp check --fix-dangerously`

dangerous fixes do not require --fix

```
pass: Formatting completed for checked files (<duration>)
pass: Found no warnings or lint errors in 2 files (<duration>, <n> 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 (<duration>, <n> threads)
pass: Found no warnings or lint errors in 2 files (<duration>, <n> threads)
```
Original file line number Diff line number Diff line change
@@ -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 (<duration>)
```

## `vpt print-file src/index.js`

```
const unused = 1;
export function greet(enabled) {
if (enabled) return "hello";
return "world";
}
```
Original file line number Diff line number Diff line change
@@ -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 (<duration>, <n> threads)
pass: Formatting completed for checked files (<duration>)
```

## `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 <duration> on 1 files using <n> threads.
No config found, using defaults. Please add a config file or try `vp fmt --init` if needed.
```
Original file line number Diff line number Diff line change
@@ -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 (<duration>, <n> 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 (<duration>)

Format issues found in above 1 files. Run without `--check` to fix.
Finished in <duration> on 1 files using <n> threads.
No config found, using defaults. Please add a config file or try `vp fmt --init` if needed.
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# check_fix_dangerously_no_lint

## `vp check --fix-dangerously --no-lint src/index.js`

```
pass: Formatting completed for checked files (<duration>)
```

## `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 (<duration>, <n> threads)
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# check_fix_dangerously_with_fix

## `vp check --fix --fix-dangerously`

```
pass: Formatting completed for checked files (<duration>)
pass: Found no warnings or lint errors in 2 files (<duration>, <n> 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 (<duration>, <n> threads)
pass: Found no warnings or lint errors in 2 files (<duration>, <n> threads)
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
const unused = 1;
export function greet(enabled) {
if (enabled) return "hello";
return "world";
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
export default {
lint: {
categories: { correctness: "off" },
rules: {
"no-unused-vars": "error",
curly: "error",
},
},
};
Original file line number Diff line number Diff line change
Expand Up @@ -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"],
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# check_fix_dangerously_no_lint_typecheck

## `vp check --fix-dangerously --no-lint`

```
pass: Formatting completed for checked files (<duration>)
pass: Found no type errors in 2 files (<duration>, <n> threads)
```

## `vpt print-file src/index.ts`

```
const value: number = 42;
export { value };
```
Original file line number Diff line number Diff line change
Expand Up @@ -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 },
]
Original file line number Diff line number Diff line change
@@ -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 (<duration>, <n> threads)
pass: Formatting completed for checked files (<duration>)
```
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
Loading
Loading