|
| 1 | +[[case]] |
| 2 | +name = "migration_existing_oxc_configs" |
| 3 | +vp = "global" |
| 4 | +steps = [ |
| 5 | + { argv = ["vp", "migrate", "--no-interactive", "--no-hooks", "--no-agent", "--no-editor"], comment = "finish a leftover Oxfmt config even when Vite+ is already installed" }, |
| 6 | + ["vpt", "print-file", "vite.config.ts"], |
| 7 | + ["vpt", "stat-file", ".oxfmtrc.json", "--assert-not", "file"], |
| 8 | + { argv = ["vp", "fmt", "src/index.ts"], comment = "the migrated options must affect formatting" }, |
| 9 | + ["vpt", "print-file", "src/index.ts"], |
| 10 | + { argv = ["vp", "migrate", "--no-interactive", "--no-hooks", "--no-agent", "--no-editor"], comment = "a completed migration should be a no-op on retry" }, |
| 11 | + ["vpt", "print-file", "vite.config.ts"], |
| 12 | + ["vpt", "stat-file", "AGENTS.md", "--assert-not", "file"], |
| 13 | + ["vpt", "stat-file", ".vite-hooks", "--assert-not", "dir"], |
| 14 | + ["vpt", "stat-file", ".vscode", "--assert-not", "dir"], |
| 15 | +] |
| 16 | + |
| 17 | +[[case]] |
| 18 | +name = "migration_existing_oxc_configs_unreferenced_lint" |
| 19 | +vp = "global" |
| 20 | +steps = [ |
| 21 | + { argv = ["vpt", "write-file", ".oxlintrc.json", "{\"rules\":{\"no-console\":\"error\"},\"options\":{\"typeAware\":false,\"typeCheck\":false}}\n"], snapshot = false }, |
| 22 | + { argv = ["vp", "migrate", "--no-interactive", "--no-hooks", "--no-agent", "--no-editor"], comment = "finish both unreferenced Oxc configs in a project that already uses Vite+" }, |
| 23 | + ["vpt", "stat-file", ".oxlintrc.json", "--assert-not", "file"], |
| 24 | + ["vpt", "stat-file", ".oxfmtrc.json", "--assert-not", "file"], |
| 25 | + ["vpt", "print-file", "vite.config.ts"], |
| 26 | + ["vp", "fmt", "src/index.ts"], |
| 27 | + ["vpt", "print-file", "src/index.ts"], |
| 28 | + ["vp", "lint", "src/index.ts"], |
| 29 | + { argv = ["vp", "migrate", "--no-interactive", "--no-hooks", "--no-agent", "--no-editor"], comment = "the restored finalization must remain a no-op on retry" }, |
| 30 | + ["vpt", "print-file", "vite.config.ts"], |
| 31 | + ["vp", "fmt", "--check", "src/index.ts"], |
| 32 | + { argv = ["vpt", "write-file", "src/index.ts", "console.log('hello')\n"], snapshot = false }, |
| 33 | + { argv = ["vp", "lint", "src/index.ts"], comment = "the merged lint rule must apply after the JSON config is removed", continue-on-failure = true }, |
| 34 | +] |
| 35 | + |
| 36 | +[[case]] |
| 37 | +name = "migration_existing_oxc_configs_inline_fmt" |
| 38 | +vp = "global" |
| 39 | +steps = [ |
| 40 | + { argv = ["vpt", "write-file", "vite.config.ts", "export default { fmt: { singleQuote: false, semi: false } };\n"], snapshot = false }, |
| 41 | + { argv = ["vp", "fmt", "src/index.ts"], comment = "the existing inline fmt config takes precedence over the standalone config" }, |
| 42 | + ["vpt", "print-file", "src/index.ts"], |
| 43 | + { argv = ["vpt", "write-file", "src/index.ts", "export const message = \"preserved\";\n"], snapshot = false }, |
| 44 | + { argv = ["vp", "migrate", "--no-interactive", "--no-hooks", "--no-agent", "--no-editor"], comment = "keep the standalone config when fmt is already configured" }, |
| 45 | + ["vpt", "print-file", "vite.config.ts"], |
| 46 | + ["vpt", "stat-file", ".oxfmtrc.json", "--assert", "file"], |
| 47 | + { argv = ["vp", "fmt", "src/index.ts"], comment = "formatting must still use the existing inline options after migration" }, |
| 48 | + ["vpt", "print-file", "src/index.ts"], |
| 49 | + { argv = ["vp", "migrate", "--no-interactive", "--no-hooks", "--no-agent", "--no-editor"], comment = "retrying the completed migration should be a no-op" }, |
| 50 | + ["vpt", "print-file", "vite.config.ts"], |
| 51 | +] |
| 52 | + |
| 53 | +[[case]] |
| 54 | +name = "migration_existing_oxc_configs_imported" |
| 55 | +vp = "global" |
| 56 | +steps = [ |
| 57 | + { argv = ["vpt", "write-file", "vite.config.ts", "import fmt from './.oxfmtrc.json' with { type: 'json' };\nimport { readFileSync } from 'node:fs';\nconst lint = JSON.parse(readFileSync(new URL('./.oxlintrc.json', import.meta.url), 'utf8'));\nexport default { fmt, lint };\n"], snapshot = false }, |
| 58 | + { argv = ["vpt", "write-file", ".oxlintrc.json", "{\"rules\":{\"no-debugger\":\"error\"}}\n"], snapshot = false }, |
| 59 | + { argv = ["vp", "migrate", "--no-interactive", "--no-hooks", "--no-agent", "--no-editor"], comment = "preserve JSON configs loaded with imports and readFileSync" }, |
| 60 | + ["vpt", "print-file", ".oxfmtrc.json"], |
| 61 | + ["vpt", "print-file", ".oxlintrc.json"], |
| 62 | + ["vp", "fmt", "src/index.ts"], |
| 63 | + ["vpt", "print-file", "src/index.ts"], |
| 64 | + ["vp", "lint", "src/index.ts"], |
| 65 | + { argv = ["vp", "migrate", "--no-interactive", "--no-hooks", "--no-agent", "--no-editor"], comment = "retry preserves both imported configs" }, |
| 66 | + ["vp", "fmt", "--check", "src/index.ts"], |
| 67 | + ["vp", "lint", "src/index.ts"], |
| 68 | +] |
| 69 | + |
| 70 | +[[case]] |
| 71 | +name = "migration_existing_oxc_configs_script" |
| 72 | +vp = "global" |
| 73 | +steps = [ |
| 74 | + { argv = ["vpt", "json-edit", "package.json", "scripts.fmt", "vp fmt -c .oxfmtrc.json src/index.ts"], snapshot = false }, |
| 75 | + { argv = ["vp", "migrate", "--no-interactive", "--no-hooks", "--no-agent", "--no-editor"], comment = "preserve the config passed explicitly by a package script" }, |
| 76 | + ["vpt", "stat-file", ".oxfmtrc.json", "--assert", "file"], |
| 77 | + ["vpt", "print-file", "vite.config.ts"], |
| 78 | + ["vp", "run", "fmt"], |
| 79 | + ["vpt", "print-file", "src/index.ts"], |
| 80 | +] |
| 81 | + |
| 82 | +[[case]] |
| 83 | +name = "migration_existing_oxc_configs_extends" |
| 84 | +vp = ["global", "local"] |
| 85 | +steps = [ |
| 86 | + { argv = ["vpt", "write-file", ".oxlintrc.json", '{"extends":["./lint-base.json"]}'], snapshot = false }, |
| 87 | + { argv = ["vpt", "write-file", "lint-base.json", '{"rules":{"no-console":"error"},"options":{"typeAware":false,"typeCheck":false}}'], snapshot = false }, |
| 88 | + { argv = ["vpt", "write-file", "src/index.ts", "console.log('hello');\n"], snapshot = false }, |
| 89 | + { argv = ["vp", "migrate", "--no-interactive", "--no-hooks", "--no-agent", "--no-editor"], comment = "recover an interrupted inheritance migration using shared TypeScript configs" }, |
| 90 | + ["vpt", "stat-file", ".oxlintrc.json", "--assert", "missing"], |
| 91 | + ["vpt", "print-file", "vite.config.ts"], |
| 92 | + ["vpt", "print-file", "lint-base.ts"], |
| 93 | + { argv = ["vp", "lint", "src/index.ts"], comment = "plain lint must enforce the inherited no-console error", continue-on-failure = true }, |
| 94 | + { argv = ["vp", "migrate", "--no-interactive", "--no-hooks", "--no-agent", "--no-editor"], continue-on-failure = true }, |
| 95 | + ["vpt", "print-file", "vite.config.ts"], |
| 96 | + { argv = ["vp", "lint", "src/index.ts"], comment = "a second migration must preserve the inherited error", continue-on-failure = true }, |
| 97 | +] |
0 commit comments