Skip to content

Commit bc5706c

Browse files
committed
test(check): add snap tests for --type-check-only
Five local cases cover the new flag's behaviors, plus the global `vp check -h` snap is refreshed to include the new flag row: - pass: no type errors with typeCheck enabled ("Found no type errors") - fail: type error with typeCheck enabled surfaces TS2322 via tsgolint - no-typecheck-config: `lint.options.typeCheck: false` does not suppress type errors when the flag is set - conflict-fix: `--type-check-only --fix` rejected with a clear message - conflict-no-lint: `--type-check-only --no-lint` rejected likewise oxlint's `--type-check-only` output uses the same "Found N error and M warning ... Finished in ..." summary that the existing analyze_lint_output parser handles, so no parser changes are needed.
1 parent 12eeede commit bc5706c

File tree

25 files changed

+173
-12
lines changed

25 files changed

+173
-12
lines changed

packages/cli/snap-tests-global/command-check-help/snap.txt

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,11 @@ Usage: vp check [OPTIONS] [PATHS]...
66
Run format, lint, and type checks.
77

88
Options:
9-
--fix Auto-fix format and lint issues
10-
--no-fmt Skip format check
11-
--no-lint Skip lint check
12-
-h, --help Print help
9+
--fix Auto-fix format and lint issues
10+
--no-fmt Skip format check
11+
--no-lint Skip lint check
12+
--type-check-only Run only type checking, skipping format and lint rules
13+
-h, --help Print help
1314

1415
Examples:
1516
vp check
@@ -27,10 +28,11 @@ Usage: vp check [OPTIONS] [PATHS]...
2728
Run format, lint, and type checks.
2829

2930
Options:
30-
--fix Auto-fix format and lint issues
31-
--no-fmt Skip format check
32-
--no-lint Skip lint check
33-
-h, --help Print help
31+
--fix Auto-fix format and lint issues
32+
--no-fmt Skip format check
33+
--no-lint Skip lint check
34+
--type-check-only Run only type checking, skipping format and lint rules
35+
-h, --help Print help
3436

3537
Examples:
3638
vp check
@@ -48,10 +50,11 @@ Usage: vp check [OPTIONS] [PATHS]...
4850
Run format, lint, and type checks.
4951

5052
Options:
51-
--fix Auto-fix format and lint issues
52-
--no-fmt Skip format check
53-
--no-lint Skip lint check
54-
-h, --help Print help
53+
--fix Auto-fix format and lint issues
54+
--no-fmt Skip format check
55+
--no-lint Skip lint check
56+
--type-check-only Run only type checking, skipping format and lint rules
57+
-h, --help Print help
5558

5659
Examples:
5760
vp check
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"name": "check-type-check-only-conflict-fix",
3+
"version": "0.0.0",
4+
"private": true
5+
}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
[1]> vp check --type-check-only --fix
2+
error: Conflicting flags
3+
4+
`vp check --type-check-only` cannot be used with `--fix`
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"env": {
3+
"VITE_DISABLE_AUTO_INSTALL": "1"
4+
},
5+
"commands": ["vp check --type-check-only --fix"]
6+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"name": "check-type-check-only-conflict-no-lint",
3+
"version": "0.0.0",
4+
"private": true
5+
}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
[1]> vp check --type-check-only --no-lint
2+
error: Conflicting flags
3+
4+
`vp check --type-check-only` cannot be used with `--no-lint`
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"env": {
3+
"VITE_DISABLE_AUTO_INSTALL": "1"
4+
},
5+
"commands": ["vp check --type-check-only --no-lint"]
6+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"name": "check-type-check-only-fail",
3+
"version": "0.0.0",
4+
"private": true
5+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
[1]> vp check --type-check-only
2+
error: Type errors found
3+
× typescript(TS2322): Type 'string' is not assignable to type 'number'.
4+
╭─[src/index.ts:2:9]
5+
1 │ export function hello(): number {
6+
2 │ const value: number = "not a number";
7+
· ─────
8+
3 │ return value;
9+
╰────
10+
11+
Found 1 error and 0 warnings in 2 files (<variable>ms, <variable> threads)
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
export function hello(): number {
2+
const value: number = "not a number";
3+
return value;
4+
}

0 commit comments

Comments
 (0)