Skip to content

Commit 0d14055

Browse files
authored
fix(create): enable typeAware and typeCheck by default in vp create (#774)
Projects created via `vp create` were missing `typeAware: true` and `typeCheck: true` in the lint config because the injection logic only ran when an existing `.oxlintrc.json` was found. Add `injectLintTypeCheckDefaults()` that runs after `mergeViteConfigFiles()` to inject these defaults when no lint config exists yet.
1 parent 880214d commit 0d14055

29 files changed

Lines changed: 117 additions & 9 deletions

File tree

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
> vp create vite:application --no-interactive # create standalone app
2+
> cat vite-plus-application/vite.config.ts # check standalone vite.config.ts has typeAware and typeCheck
3+
import { defineConfig } from "vite-plus";
4+
5+
export default defineConfig({
6+
staged: {
7+
"*": "vp check --fix",
8+
},
9+
lint: { options: { typeAware: true, typeCheck: true } },
10+
});
11+
12+
> vp create vite:monorepo --no-interactive # create monorepo
13+
> cat vite-plus-monorepo/vite.config.ts # check monorepo root vite.config.ts has typeAware and typeCheck
14+
import { defineConfig } from "vite-plus";
15+
16+
export default defineConfig({
17+
staged: {
18+
"*": "vp check --fix",
19+
},
20+
lint: { options: { typeAware: true, typeCheck: true } },
21+
});
22+
23+
> cat vite-plus-monorepo/apps/website/vite.config.ts 2>&1 || true # sub-app should NOT have typeAware/typeCheck
24+
cat: vite-plus-monorepo/apps/website/vite.config.ts: No such file or directory
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{
2+
"commands": [
3+
{
4+
"command": "vp create vite:application --no-interactive # create standalone app",
5+
"ignoreOutput": true
6+
},
7+
"cat vite-plus-application/vite.config.ts # check standalone vite.config.ts has typeAware and typeCheck",
8+
{
9+
"command": "vp create vite:monorepo --no-interactive # create monorepo",
10+
"ignoreOutput": true
11+
},
12+
"cat vite-plus-monorepo/vite.config.ts # check monorepo root vite.config.ts has typeAware and typeCheck",
13+
"cat vite-plus-monorepo/apps/website/vite.config.ts 2>&1 || true # sub-app should NOT have typeAware/typeCheck"
14+
]
15+
}

packages/cli/snap-tests-global/migration-chained-lint-staged-pre-commit/snap.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,10 @@ VITE+ - The Unified Toolchain for the Web
3030
import { defineConfig } from 'vite-plus';
3131

3232
export default defineConfig({
33+
lint: {"options":{"typeAware":true,"typeCheck":true}},
3334
staged: {
3435
"*.js": "vp lint --fix"
3536
},
36-
3737
});
3838

3939
> cat .vite-hooks/pre-commit # check npx lint-staged replaced but --diff HEAD~1 && npm test preserved

packages/cli/snap-tests-global/migration-env-prefix-lint-staged/snap.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,10 @@ VITE+ - The Unified Toolchain for the Web
3030
import { defineConfig } from 'vite-plus';
3131

3232
export default defineConfig({
33+
lint: {"options":{"typeAware":true,"typeCheck":true}},
3334
staged: {
3435
"*.js": "vp lint --fix"
3536
},
36-
3737
});
3838

3939
> cat .vite-hooks/pre-commit # check env prefix preserved with vp staged

packages/cli/snap-tests-global/migration-existing-husky-lint-staged/snap.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,10 @@ VITE+ - The Unified Toolchain for the Web
3030
import { defineConfig } from 'vite-plus';
3131

3232
export default defineConfig({
33+
lint: {"options":{"typeAware":true,"typeCheck":true}},
3334
staged: {
3435
"*.js": "vp lint --fix"
3536
},
36-
3737
});
3838

3939
> cat .vite-hooks/pre-commit # check pre-commit hook rewritten

packages/cli/snap-tests-global/migration-existing-husky-v8-hooks/snap.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ VITE+ - The Unified Toolchain for the Web
66
⚠ Detected husky <9.0.0 — please upgrade to husky v9+ first, then re-run migration.
77
◇ Migrated . to Vite+<repeat>
88
• Node <semver> pnpm <semver>
9+
• 1 config update applied
910

1011
> cat package.json # husky/lint-staged should remain in devDeps, prepare should stay as husky
1112
{

packages/cli/snap-tests-global/migration-existing-husky-v8-multi-hooks/snap.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ VITE+ - The Unified Toolchain for the Web
66
⚠ Detected husky <9.0.0 — please upgrade to husky v9+ first, then re-run migration.
77
◇ Migrated . to Vite+<repeat>
88
• Node <semver> pnpm <semver>
9+
• 1 config update applied
910

1011
> cat package.json # husky/lint-staged should remain in devDeps, prepare should stay as husky
1112
{

packages/cli/snap-tests-global/migration-existing-lint-staged-config/snap.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,10 @@ cat: .lintstagedrc.json: No such file or directory
3333
import { defineConfig } from 'vite-plus';
3434

3535
export default defineConfig({
36+
lint: {"options":{"typeAware":true,"typeCheck":true}},
3637
staged: {
3738
"*.ts": "vp lint --fix"
3839
},
39-
4040
});
4141

4242
> cat .vite-hooks/pre-commit # check pre-commit hook created

packages/cli/snap-tests-global/migration-existing-pnpm-exec-lint-staged/snap.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,10 @@ VITE+ - The Unified Toolchain for the Web
3030
import { defineConfig } from 'vite-plus';
3131

3232
export default defineConfig({
33+
lint: {"options":{"typeAware":true,"typeCheck":true}},
3334
staged: {
3435
"*.js": "vp lint --fix"
3536
},
36-
3737
});
3838

3939
> cat .vite-hooks/pre-commit # check pnpm exec lint-staged replaced with vp staged

packages/cli/snap-tests-global/migration-from-tsdown-json-config/snap.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ export default defineConfig({
2424
"cwd": "./src"
2525
}
2626
},
27+
lint: {"options":{"typeAware":true,"typeCheck":true}},
2728
server: {
2829
port: 3000,
2930
},
@@ -73,6 +74,7 @@ export default defineConfig({
7374
"cwd": "./src"
7475
}
7576
},
77+
lint: {"options":{"typeAware":true,"typeCheck":true}},
7678
server: {
7779
port: 3000,
7880
},

0 commit comments

Comments
 (0)