Skip to content

Commit 2795ba3

Browse files
committed
test(cli/create): pin create-vite version, cat vite.config.ts, run on windows
Addresses review feedback on the new-create-vite-migrates-eslint-prettier snap test: - Switch from `vp create vite:application --directory my-react-ts` to `vp create vite@9.0.5 -- my-react-ts --template react-ts`. Pinning create-vite to 9.0.5 makes the snap stable against upstream template changes, and the project name is passed as a positional (which is what create-vite expects; `--directory` is rejected for remote templates). - Add `cat my-react-ts/vite.config.ts` so the snap captures the full merged config (oxlint `lint: { ... }` block + `fmt: {}` section), making the parity with `vp migrate` directly visible in diffs. - Drop `ignoredPlatforms: ["win32"]` — nothing in this flow is Windows-specific.
1 parent 2b83e26 commit 2795ba3

2 files changed

Lines changed: 126 additions & 6 deletions

File tree

packages/cli/snap-tests-global/new-create-vite-migrates-eslint-prettier/snap.txt

Lines changed: 124 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,133 @@
1-
> vp create vite:application --no-interactive --directory my-react-ts -- --template react-ts # create vite app with react-ts template, should auto-migrate ESLint -> Oxlint and merge lint config into vite.config.ts
1+
> vp create vite@9.0.5 --no-interactive -- my-react-ts --template react-ts # create vite app with pinned version + react-ts template, should auto-migrate ESLint -> Oxlint and merge lint config into vite.config.ts
22
> test ! -f my-react-ts/eslint.config.js && echo 'eslint.config.js removed' # eslint config deleted
33
eslint.config.js removed
44

55
> test ! -f my-react-ts/.oxlintrc.json && echo '.oxlintrc.json merged into vite.config.ts' # migration output merged by rewrite step (matches vp migrate)
66
.oxlintrc.json merged into vite.config.ts
77

8-
> grep -q 'lint:' my-react-ts/vite.config.ts && echo 'vite.config.ts has lint section' # oxlint config merged into vite.config.ts
9-
vite.config.ts has lint section
8+
> cat my-react-ts/vite.config.ts # merged vite config should contain lint and fmt sections
9+
import { defineConfig } from "vite-plus";
10+
import react from "@vitejs/plugin-react";
11+
12+
// https://vite.dev/config/
13+
export default defineConfig({
14+
staged: {
15+
"*": "vp check --fix",
16+
},
17+
fmt: {},
18+
lint: {
19+
plugins: ["oxc", "typescript", "unicorn", "react"],
20+
categories: {
21+
correctness: "warn",
22+
},
23+
env: {
24+
builtin: true,
25+
},
26+
ignorePatterns: ["dist"],
27+
overrides: [
28+
{
29+
files: ["**/*.{ts,tsx}"],
30+
rules: {
31+
"constructor-super": "error",
32+
"for-direction": "error",
33+
"getter-return": "error",
34+
"no-async-promise-executor": "error",
35+
"no-case-declarations": "error",
36+
"no-class-assign": "error",
37+
"no-compare-neg-zero": "error",
38+
"no-cond-assign": "error",
39+
"no-const-assign": "error",
40+
"no-constant-binary-expression": "error",
41+
"no-constant-condition": "error",
42+
"no-control-regex": "error",
43+
"no-debugger": "error",
44+
"no-delete-var": "error",
45+
"no-dupe-class-members": "error",
46+
"no-dupe-else-if": "error",
47+
"no-dupe-keys": "error",
48+
"no-duplicate-case": "error",
49+
"no-empty": "error",
50+
"no-empty-character-class": "error",
51+
"no-empty-pattern": "error",
52+
"no-empty-static-block": "error",
53+
"no-ex-assign": "error",
54+
"no-extra-boolean-cast": "error",
55+
"no-fallthrough": "error",
56+
"no-func-assign": "error",
57+
"no-global-assign": "error",
58+
"no-import-assign": "error",
59+
"no-invalid-regexp": "error",
60+
"no-irregular-whitespace": "error",
61+
"no-loss-of-precision": "error",
62+
"no-misleading-character-class": "error",
63+
"no-new-native-nonconstructor": "error",
64+
"no-nonoctal-decimal-escape": "error",
65+
"no-obj-calls": "error",
66+
"no-prototype-builtins": "error",
67+
"no-redeclare": "error",
68+
"no-regex-spaces": "error",
69+
"no-self-assign": "error",
70+
"no-setter-return": "error",
71+
"no-shadow-restricted-names": "error",
72+
"no-sparse-arrays": "error",
73+
"no-this-before-super": "error",
74+
"no-undef": "error",
75+
"no-unexpected-multiline": "error",
76+
"no-unreachable": "error",
77+
"no-unsafe-finally": "error",
78+
"no-unsafe-negation": "error",
79+
"no-unsafe-optional-chaining": "error",
80+
"no-unused-labels": "error",
81+
"no-unused-private-class-members": "error",
82+
"no-unused-vars": "error",
83+
"no-useless-backreference": "error",
84+
"no-useless-catch": "error",
85+
"no-useless-escape": "error",
86+
"no-with": "error",
87+
"require-yield": "error",
88+
"use-isnan": "error",
89+
"valid-typeof": "error",
90+
"no-array-constructor": "error",
91+
"no-unused-expressions": "error",
92+
"typescript/ban-ts-comment": "error",
93+
"typescript/no-duplicate-enum-values": "error",
94+
"typescript/no-empty-object-type": "error",
95+
"typescript/no-explicit-any": "error",
96+
"typescript/no-extra-non-null-assertion": "error",
97+
"typescript/no-misused-new": "error",
98+
"typescript/no-namespace": "error",
99+
"typescript/no-non-null-asserted-optional-chain": "error",
100+
"typescript/no-require-imports": "error",
101+
"typescript/no-this-alias": "error",
102+
"typescript/no-unnecessary-type-constraint": "error",
103+
"typescript/no-unsafe-declaration-merging": "error",
104+
"typescript/no-unsafe-function-type": "error",
105+
"typescript/no-wrapper-object-types": "error",
106+
"typescript/prefer-as-const": "error",
107+
"typescript/prefer-namespace-keyword": "error",
108+
"typescript/triple-slash-reference": "error",
109+
"react/rules-of-hooks": "error",
110+
"react/exhaustive-deps": "warn",
111+
"react/only-export-components": [
112+
"error",
113+
{
114+
allowConstantExport: true,
115+
},
116+
],
117+
},
118+
env: {
119+
es2020: true,
120+
browser: true,
121+
},
122+
},
123+
],
124+
options: {
125+
typeAware: true,
126+
typeCheck: true,
127+
},
128+
},
129+
plugins: [react()],
130+
});
10131

11132
> node -e "const p=require('./my-react-ts/package.json');console.log('lint:', p.scripts && p.scripts.lint);console.log('eslint dep:', !!(p.devDependencies && p.devDependencies.eslint));console.log('vite-plus dep:', !!(p.devDependencies && p.devDependencies['vite-plus']));" # scripts rewritten, eslint dep removed, vite-plus added
12133
lint: vp lint .
Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,16 @@
11
{
2-
"ignoredPlatforms": ["win32"],
32
"env": {
43
"VP_SKIP_INSTALL": "",
54
"CI": ""
65
},
76
"commands": [
87
{
9-
"command": "vp create vite:application --no-interactive --directory my-react-ts -- --template react-ts # create vite app with react-ts template, should auto-migrate ESLint -> Oxlint and merge lint config into vite.config.ts",
8+
"command": "vp create vite@9.0.5 --no-interactive -- my-react-ts --template react-ts # create vite app with pinned version + react-ts template, should auto-migrate ESLint -> Oxlint and merge lint config into vite.config.ts",
109
"ignoreOutput": true
1110
},
1211
"test ! -f my-react-ts/eslint.config.js && echo 'eslint.config.js removed' # eslint config deleted",
1312
"test ! -f my-react-ts/.oxlintrc.json && echo '.oxlintrc.json merged into vite.config.ts' # migration output merged by rewrite step (matches vp migrate)",
14-
"grep -q 'lint:' my-react-ts/vite.config.ts && echo 'vite.config.ts has lint section' # oxlint config merged into vite.config.ts",
13+
"cat my-react-ts/vite.config.ts # merged vite config should contain lint and fmt sections",
1514
"node -e \"const p=require('./my-react-ts/package.json');console.log('lint:', p.scripts && p.scripts.lint);console.log('eslint dep:', !!(p.devDependencies && p.devDependencies.eslint));console.log('vite-plus dep:', !!(p.devDependencies && p.devDependencies['vite-plus']));\" # scripts rewritten, eslint dep removed, vite-plus added"
1615
]
1716
}

0 commit comments

Comments
 (0)