Skip to content

Commit 962c7e7

Browse files
committed
fix(cli): preserve workspace config selection in vp check
1 parent 7181545 commit 962c7e7

21 files changed

Lines changed: 275 additions & 30 deletions

‎crates/vp_cli_snapshots/tests/cli_snapshots/fixtures/workspace_fmt_root_config/snapshots.toml‎

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@ vp = ["local", "global"]
44
cwd = "packages/app"
55
steps = [
66
{ argv = ["vp", "fmt", "--check", "index.js"], comment = "Oxfmt discovers the package format settings.", continue-on-failure = true },
7-
{ argv = ["vp", "check", "--no-lint", "index.js"], comment = "The formatting phase of check also discovers the package config.", continue-on-failure = true },
7+
{ argv = ["vp", "check", "--no-lint", "index.js"], comment = "The check command keeps the root format settings.", continue-on-failure = true },
88
{ argv = ["vp", "fmt", "index.js"] },
99
{ argv = ["vpt", "print-file", "index.js"], comment = "The package double-quote and semicolon settings apply with package-relative file paths." },
10-
{ argv = ["vp", "check", "--no-lint", "index.js"] },
10+
{ argv = ["vp", "check", "--no-lint", "index.js"], comment = "Direct formatting does not change the root settings used by check.", continue-on-failure = true },
1111
]
1212

1313
[[case]]
@@ -22,11 +22,32 @@ steps = [
2222
]
2323

2424
[[case]]
25-
name = "check_fix_uses_discovered_format"
25+
name = "check_fix_uses_root_format"
2626
vp = "local"
2727
cwd = "packages/app"
2828
steps = [
2929
{ argv = ["vp", "check", "--fix", "fix.js"] },
30-
{ argv = ["vpt", "print-file", "fix.js"], comment = "Formatting after the root curly lint fix uses package quotes and semicolons." },
30+
{ argv = ["vpt", "print-file", "fix.js"], comment = "Formatting after the curly lint fix also uses root quotes and semicolons." },
3131
{ argv = ["vp", "check", "fix.js"] },
3232
]
33+
34+
[[case]]
35+
name = "check_without_root_format"
36+
vp = "local"
37+
cwd = "packages/app"
38+
steps = [
39+
{ argv = ["vpt", "write-file", "../../vite.config.ts", "export default { lint: {} };\n"], snapshot = false },
40+
{ argv = ["vpt", "write-file", "vite.config.ts", "export default { fmt: { singleQuote: true, semi: false } };\n"], snapshot = false },
41+
{ argv = ["vpt", "write-file", "index.js", "export const message = 'hello'\n"], snapshot = false },
42+
{ argv = ["vp", "check", "--no-lint", "index.js"], comment = "Without a root fmt block, check lets Oxfmt discover the package format settings." },
43+
]
44+
45+
[[case]]
46+
name = "check_explicit_format_config"
47+
vp = "local"
48+
cwd = "packages/app"
49+
steps = [
50+
{ argv = ["vp", "check", "--no-lint", "--", "-c", "vite.config.ts", "index.js"], comment = "An explicit config passed through check still takes precedence over the root config." },
51+
{ argv = ["vp", "check", "--no-lint", "--", "--config", "vite.config.ts", "index.js"] },
52+
{ argv = ["vp", "check", "--no-lint", "--", "--config=vite.config.ts", "index.js"] },
53+
]
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# check_explicit_format_config
2+
3+
## `vp check --no-lint -- -c vite.config.ts index.js`
4+
5+
An explicit config passed through check still takes precedence over the root config.
6+
7+
```
8+
pass: All 1 file are correctly formatted (<duration>, <n> threads)
9+
```
10+
11+
## `vp check --no-lint -- --config vite.config.ts index.js`
12+
13+
```
14+
pass: All 1 file are correctly formatted (<duration>, <n> threads)
15+
```
16+
17+
## `vp check --no-lint -- --config=vite.config.ts index.js`
18+
19+
```
20+
pass: All 1 file are correctly formatted (<duration>, <n> threads)
21+
```

crates/vp_cli_snapshots/tests/cli_snapshots/fixtures/workspace_fmt_root_config/snapshots/check_fix_uses_discovered_format.md renamed to crates/vp_cli_snapshots/tests/cli_snapshots/fixtures/workspace_fmt_root_config/snapshots/check_fix_uses_root_format.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# check_fix_uses_discovered_format
1+
# check_fix_uses_root_format
22

33
## `vp check --fix fix.js`
44

@@ -9,12 +9,12 @@ pass: Found no warnings or lint errors in 1 file (<duration>, <n> threads)
99

1010
## `vpt print-file fix.js`
1111

12-
Formatting after the root curly lint fix uses package quotes and semicolons.
12+
Formatting after the curly lint fix also uses root quotes and semicolons.
1313

1414
```
1515
export function greet(show) {
1616
if (show) {
17-
console.log("hello");
17+
console.log('hello')
1818
}
1919
}
2020
```
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# check_without_root_format
2+
3+
## `vpt write-file ../../vite.config.ts 'export default { lint: {} };
4+
'`
5+
6+
7+
## `vpt write-file vite.config.ts 'export default { fmt: { singleQuote: true, semi: false } };
8+
'`
9+
10+
11+
## `vpt write-file index.js 'export const message = '\''hello'\''
12+
'`
13+
14+
15+
## `vp check --no-lint index.js`
16+
17+
Without a root fmt block, check lets Oxfmt discover the package format settings.
18+
19+
```
20+
pass: All 1 file are correctly formatted (<duration>, <n> threads)
21+
```

‎crates/vp_cli_snapshots/tests/cli_snapshots/fixtures/workspace_fmt_root_config/snapshots/discovered_format_options.global.md‎

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,17 @@ Finished in <duration> on 1 files using <n> threads.
1515

1616
## `vp check --no-lint index.js`
1717

18-
The formatting phase of check also discovers the package config.
18+
The check command keeps the root format settings.
19+
20+
**Exit code:** 1
1921

2022
```
2123
VITE+ - The Unified Toolchain for the Web
2224
23-
pass: All 1 file are correctly formatted (<duration>, <n> threads)
25+
error: Formatting issues found
26+
index.js (<duration>)
27+
28+
Found formatting issues in 1 file (<duration>, <n> threads). Run `vp check --fix` to fix them.
2429
```
2530

2631
## `vp fmt index.js`
@@ -41,8 +46,15 @@ export const message = "hello";
4146

4247
## `vp check --no-lint index.js`
4348

49+
Direct formatting does not change the root settings used by check.
50+
51+
**Exit code:** 1
52+
4453
```
4554
VITE+ - The Unified Toolchain for the Web
4655
47-
pass: All 1 file are correctly formatted (<duration>, <n> threads)
56+
error: Formatting issues found
57+
index.js (<duration>)
58+
59+
Found formatting issues in 1 file (<duration>, <n> threads). Run `vp check --fix` to fix them.
4860
```

‎crates/vp_cli_snapshots/tests/cli_snapshots/fixtures/workspace_fmt_root_config/snapshots/discovered_format_options.local.md‎

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,15 @@ Finished in <duration> on 1 files using <n> threads.
1313

1414
## `vp check --no-lint index.js`
1515

16-
The formatting phase of check also discovers the package config.
16+
The check command keeps the root format settings.
17+
18+
**Exit code:** 1
1719

1820
```
19-
pass: All 1 file are correctly formatted (<duration>, <n> threads)
21+
error: Formatting issues found
22+
index.js (<duration>)
23+
24+
Found formatting issues in 1 file (<duration>, <n> threads). Run `vp check --fix` to fix them.
2025
```
2126

2227
## `vp fmt index.js`
@@ -35,6 +40,13 @@ export const message = "hello";
3540

3641
## `vp check --no-lint index.js`
3742

43+
Direct formatting does not change the root settings used by check.
44+
45+
**Exit code:** 1
46+
3847
```
39-
pass: All 1 file are correctly formatted (<duration>, <n> threads)
48+
error: Formatting issues found
49+
index.js (<duration>)
50+
51+
Found formatting issues in 1 file (<duration>, <n> threads). Run `vp check --fix` to fix them.
4052
```

‎crates/vp_cli_snapshots/tests/cli_snapshots/fixtures/workspace_lint_root_config/snapshots.toml‎

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ vp = ["local", "global"]
44
cwd = "packages/app"
55
steps = [
66
{ argv = ["vp", "lint", "index.ts"], comment = "Oxlint discovers the package lint block without the root rules or type-check options.", continue-on-failure = true },
7-
{ argv = ["vp", "check", "--no-fmt", "index.ts"], comment = "The lint phase of check also lets Oxlint discover the package config.", continue-on-failure = true },
7+
{ argv = ["vp", "check", "--no-fmt", "index.ts"], comment = "The check command keeps the root lint rules and type-check options.", continue-on-failure = true },
88
{ argv = ["vp", "check", "--no-fmt", "--no-lint", "index.ts"], comment = "Type-check-only mode still reports the type error without lint rules.", continue-on-failure = true },
99
{ argv = ["vp", "lint", "-c", "../../vite.config.ts", "index.ts"], comment = "Explicit root selection enables the root rules and type checking while preserving package-relative file paths.", continue-on-failure = true },
1010
]
@@ -16,8 +16,28 @@ cwd = "packages/app"
1616
steps = [
1717
{ argv = ["vpt", "write-file", "vite.config.ts", "export default { lint: { options: { typeAware: false, typeCheck: false }, rules: { 'no-console': 'off' } } };\n"], snapshot = false },
1818
{ argv = ["vp", "lint", "index.ts"], comment = "Oxlint uses the package rules and type-check options.", continue-on-failure = true },
19-
{ argv = ["vp", "check", "--no-fmt", "index.ts"], continue-on-failure = true },
19+
{ argv = ["vp", "check", "--no-fmt", "index.ts"], comment = "Package options cannot disable the root rules or type checking in check.", continue-on-failure = true },
2020
{ argv = ["vp", "lint", "-c", "vite.config.ts", "index.ts"], comment = "An explicit package config matches native discovery." },
2121
{ argv = ["vp", "lint", "--config", "vite.config.ts", "index.ts"] },
2222
{ argv = ["vp", "lint", "--config=vite.config.ts", "index.ts"] },
2323
]
24+
25+
[[case]]
26+
name = "check_without_root_lint"
27+
vp = "local"
28+
cwd = "packages/app"
29+
steps = [
30+
{ argv = ["vpt", "write-file", "../../vite.config.ts", "export default { fmt: {} };\n"], snapshot = false },
31+
{ argv = ["vpt", "write-file", "vite.config.ts", "export default { lint: { rules: { 'no-console': 'error' } } };\n"], snapshot = false },
32+
{ argv = ["vp", "check", "--no-fmt", "index.ts"], comment = "Without a root lint block, check lets Oxlint discover the package lint rules.", continue-on-failure = true },
33+
]
34+
35+
[[case]]
36+
name = "check_explicit_lint_config"
37+
vp = "local"
38+
cwd = "packages/app"
39+
steps = [
40+
{ argv = ["vp", "check", "--no-fmt", "--", "-c", "vite.config.ts", "index.ts"], comment = "An explicit config passed through check still takes precedence over the root config." },
41+
{ argv = ["vp", "check", "--no-fmt", "--", "--config", "vite.config.ts", "index.ts"] },
42+
{ argv = ["vp", "check", "--no-fmt", "--", "--config=vite.config.ts", "index.ts"] },
43+
]
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# check_explicit_lint_config
2+
3+
## `vp check --no-fmt -- -c vite.config.ts index.ts`
4+
5+
An explicit config passed through check still takes precedence over the root config.
6+
7+
```
8+
pass: Found no warnings, lint errors, or type errors in 1 file (<duration>, <n> threads)
9+
```
10+
11+
## `vp check --no-fmt -- --config vite.config.ts index.ts`
12+
13+
```
14+
pass: Found no warnings, lint errors, or type errors in 1 file (<duration>, <n> threads)
15+
```
16+
17+
## `vp check --no-fmt -- --config=vite.config.ts index.ts`
18+
19+
```
20+
pass: Found no warnings, lint errors, or type errors in 1 file (<duration>, <n> threads)
21+
```
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# check_without_root_lint
2+
3+
## `vpt write-file ../../vite.config.ts 'export default { fmt: {} };
4+
'`
5+
6+
7+
## `vpt write-file vite.config.ts 'export default { lint: { rules: { '\''no-console'\'': '\''error'\'' } } };
8+
'`
9+
10+
11+
## `vp check --no-fmt index.ts`
12+
13+
Without a root lint block, check lets Oxlint discover the package lint rules.
14+
15+
**Exit code:** 1
16+
17+
```
18+
error: Lint issues found
19+
× eslint(no-console): Unexpected console statement.
20+
╭─[index.ts:2:1]
21+
1 │ export const value: number = "not a number";
22+
2 │ console.log(value);
23+
· ───────────
24+
╰────
25+
help: Delete this console statement.
26+
27+
Found 1 error and 0 warnings in 1 file (<duration>, <n> threads)
28+
```

‎crates/vp_cli_snapshots/tests/cli_snapshots/fixtures/workspace_lint_root_config/snapshots/conflicting_package_options.md‎

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,28 @@ Finished in <duration> on 1 file with <n> rules using <n> threads.
1515

1616
## `vp check --no-fmt index.ts`
1717

18+
Package options cannot disable the root rules or type checking in check.
19+
20+
**Exit code:** 1
21+
1822
```
19-
pass: Found no warnings, lint errors, or type errors in 1 file (<duration>, <n> threads)
23+
error: Lint or type issues found
24+
× eslint(no-console): Unexpected console statement.
25+
╭─[index.ts:2:1]
26+
1 │ export const value: number = "not a number";
27+
2 │ console.log(value);
28+
· ───────────
29+
╰────
30+
help: Delete this console statement.
31+
32+
× typescript(TS2322): Type 'string' is not assignable to type 'number'.
33+
╭─[index.ts:1:14]
34+
1 │ export const value: number = "not a number";
35+
· ─────
36+
2 │ console.log(value);
37+
╰────
38+
39+
Found 2 errors and 0 warnings in 1 file (<duration>, <n> threads)
2040
```
2141

2242
## `vp lint -c vite.config.ts index.ts`

0 commit comments

Comments
 (0)