From 6d509caf9176d96a0272765e89cf033ba321ee51 Mon Sep 17 00:00:00 2001 From: MK Date: Mon, 9 Mar 2026 16:42:39 +0800 Subject: [PATCH 1/8] refactor: replace custom OxlintConfig with oxlint package export Remove the 874-line hand-written oxlint-config.ts and import OxlintConfig directly from the oxlint package, which already exports the same type. Clean up related lint overrides and typos exclusions for the deleted file. --- Cargo.lock | 211 +++++++++--------- crates/vite_global_cli/src/help.rs | 2 - crates/vite_migration/src/package.rs | 8 +- packages/cli/binding/src/cli.rs | 35 +-- .../snap.txt | 4 + .../migration-eslint-lint-staged/snap.txt | 4 + .../migration-eslint-lintstagedrc/snap.txt | 4 + .../snap.txt | 4 + .../migration-eslint-rerun-mjs/snap.txt | 4 + .../migration-eslint-rerun/snap.txt | 4 + .../migration-eslint/snap.txt | 4 + .../migration-merge-vite-config-js/snap.txt | 4 + .../migration-merge-vite-config-ts/snap.txt | 4 + .../migration-monorepo-pnpm/snap.txt | 8 + .../migration-monorepo-yarn4/snap.txt | 4 + .../new-vite-monorepo/snap.txt | 4 +- .../check-no-type-aware/package.json | 5 - .../snap-tests/check-no-type-aware/snap.txt | 3 - .../check-no-type-aware/src/index.js | 5 - .../snap-tests/check-no-type-aware/steps.json | 6 - .../check-no-type-check/package.json | 5 - .../snap-tests/check-no-type-check/snap.txt | 3 - .../check-no-type-check/src/index.js | 5 - .../snap-tests/check-no-type-check/steps.json | 6 - .../command-init-inline-config/snap.txt | 2 +- .../cli/src/__tests__/init-config.spec.ts | 10 +- packages/cli/src/init-config.ts | 5 +- packages/cli/src/migration/migrator.ts | 13 ++ packages/cli/src/utils/editor.ts | 1 - packages/cli/templates/monorepo/package.json | 2 +- vite.config.ts | 4 + 31 files changed, 193 insertions(+), 190 deletions(-) delete mode 100644 packages/cli/snap-tests/check-no-type-aware/package.json delete mode 100644 packages/cli/snap-tests/check-no-type-aware/snap.txt delete mode 100644 packages/cli/snap-tests/check-no-type-aware/src/index.js delete mode 100644 packages/cli/snap-tests/check-no-type-aware/steps.json delete mode 100644 packages/cli/snap-tests/check-no-type-check/package.json delete mode 100644 packages/cli/snap-tests/check-no-type-check/snap.txt delete mode 100644 packages/cli/snap-tests/check-no-type-check/src/index.js delete mode 100644 packages/cli/snap-tests/check-no-type-check/steps.json diff --git a/Cargo.lock b/Cargo.lock index 6eec0f4058..f030bed385 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1306,9 +1306,9 @@ checksum = "d7a1e2f27636f116493b8b860f5546edb47c8d8f8ea73e1d2a20be88e28d1fea" [[package]] name = "deflate64" -version = "0.1.10" +version = "0.1.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "26bf8fc351c5ed29b5c2f0cbbac1b209b74f60ecd62e675a998df72c49af5204" +checksum = "807800ff3288b621186fe0a8f3392c4652068257302709c24efd918c3dffcdc2" [[package]] name = "deranged" @@ -1539,12 +1539,6 @@ dependencies = [ "log", ] -[[package]] -name = "env_home" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c7f84e12ccf0a7ddc17a6c41c93326024c42920d7ee630d04950e6926645c0fe" - [[package]] name = "env_logger" version = "0.11.9" @@ -1570,7 +1564,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "39cab71617ae0d63f51a36d69f866391735b51691dbda63cf6f96d042b63efeb" dependencies = [ "libc", - "windows-sys 0.52.0", + "windows-sys 0.61.2", ] [[package]] @@ -1625,9 +1619,9 @@ dependencies = [ [[package]] name = "fast-glob" -version = "1.0.0" +version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3d26eec0ae9682c457cb0f85de67ad417b716ae852736a5d94c2ad6e92a997c9" +checksum = "3b9e81515b0279bf618200fd15d132e7195d2048fb46eed6f0f3c10cbc068266" dependencies = [ "arrayvec", ] @@ -1781,7 +1775,7 @@ dependencies = [ "tokio", "which", "winapi", - "winsafe 0.0.24", + "winsafe", "xxhash-rust", ] @@ -1822,7 +1816,7 @@ dependencies = [ "smallvec 2.0.0-alpha.12", "widestring", "winapi", - "winsafe 0.0.24", + "winsafe", ] [[package]] @@ -2011,20 +2005,20 @@ dependencies = [ "cfg-if", "js-sys", "libc", - "r-efi", + "r-efi 5.3.0", "wasip2", "wasm-bindgen", ] [[package]] name = "getrandom" -version = "0.4.1" +version = "0.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "139ef39800118c7683f2fd3c98c1b23c09ae076556b435f8e9064ae108aaeeec" +checksum = "0de51e6874e94e7bf76d726fc5d13ba782deca734ff60d5bb2fb2607c7406555" dependencies = [ "cfg-if", "libc", - "r-efi", + "r-efi 6.0.0", "wasip2", "wasip3", ] @@ -2339,7 +2333,7 @@ dependencies = [ "libc", "percent-encoding", "pin-project-lite", - "socket2 0.5.10", + "socket2 0.6.3", "tokio", "tower-service", "tracing", @@ -2550,9 +2544,9 @@ dependencies = [ [[package]] name = "inotify" -version = "0.11.0" +version = "0.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f37dccff2791ab604f9babef0ba14fbe0be30bd368dc541e2b08d07c8aa908f3" +checksum = "bd5b3eaf1a28b758ac0faa5a4254e8ab2705605496f1b1f3fbbc3988ad73d199" dependencies = [ "bitflags 2.11.0", "inotify-sys", @@ -2591,9 +2585,9 @@ dependencies = [ [[package]] name = "ipnet" -version = "2.11.0" +version = "2.12.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "469fb0b9cefa57e3ef31275ee7cacb78f2fdca44e4765491884a2b119d4eb130" +checksum = "d98f6fed1fde3f8c21bc40a1abb88dd75e67924f9cffc3ef95607bad8017f8e2" [[package]] name = "iri-string" @@ -2613,7 +2607,7 @@ checksum = "3640c1c38b8e4e43584d8df18be5fc6b0aa314ce6ebf51b53313d4306cca8e46" dependencies = [ "hermit-abi", "libc", - "windows-sys 0.52.0", + "windows-sys 0.61.2", ] [[package]] @@ -2673,9 +2667,9 @@ dependencies = [ [[package]] name = "js-sys" -version = "0.3.89" +version = "0.3.91" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f4eacb0641a310445a4c513f2a5e23e19952e269c6a38887254d5f837a305506" +checksum = "b49715b7073f385ba4bc528e5747d02e66cb39c6146efb66b781f131f0fb399c" dependencies = [ "once_cell", "wasm-bindgen", @@ -2834,9 +2828,9 @@ checksum = "2c4a545a15244c7d945065b5d392b2d2d7f21526fba56ce51467b06ed445e8f7" [[package]] name = "libc" -version = "0.2.182" +version = "0.2.183" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6800badb6cb2082ffd7b6a67e6125bb39f18782f793520caee8cb8846be06112" +checksum = "b5b646652bf6661599e1da8901b3b9522896f01e736bad5f723fe7a3a27f899d" [[package]] name = "libloading" @@ -2861,13 +2855,14 @@ dependencies = [ [[package]] name = "libredox" -version = "0.1.12" +version = "0.1.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3d0b95e02c851351f877147b7deea7b1afb1df71b63aa5f8270716e0c5720616" +checksum = "1744e39d1d6a9948f4f388969627434e31128196de472883b39f148769bfe30a" dependencies = [ "bitflags 2.11.0", "libc", - "redox_syscall 0.7.1", + "plain", + "redox_syscall 0.7.3", ] [[package]] @@ -3900,9 +3895,9 @@ dependencies = [ [[package]] name = "oxc_resolver" -version = "11.19.0" +version = "11.19.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9e80d8d09f2231a841bbc0d4c8ee91b8542fa1f74f6e02c43161d394415577cc" +checksum = "5632fcd47d4fdaf7ef5ee150c7001fa8ed814ce38d1a073536a366dbfc239aad" dependencies = [ "cfg-if", "compact_str", @@ -3928,9 +3923,9 @@ dependencies = [ [[package]] name = "oxc_resolver_napi" -version = "11.19.0" +version = "11.19.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1dc3036c12094eae022305f9a2647fe7e00b4c2482b78b5c64b8a0e78e32398d" +checksum = "8c961d87777f4f2d0e16e203701a0308e41ff4738254ca1fc4b238dad2e096d5" dependencies = [ "fancy-regex", "napi", @@ -4331,18 +4326,18 @@ checksum = "5be167a7af36ee22fe3115051bc51f6e6c7054c9348e28deb4f49bd6f705a315" [[package]] name = "pin-project" -version = "1.1.10" +version = "1.1.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "677f1add503faace112b9f1373e43e9e054bfdd22ff1a63c1bc485eaec6a6a8a" +checksum = "f1749c7ed4bcaf4c3d0a3efc28538844fb29bcdd7d2b67b2be7e20ba861ff517" dependencies = [ "pin-project-internal", ] [[package]] name = "pin-project-internal" -version = "1.1.10" +version = "1.1.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6e918e4ff8c4549eb882f14b3a4bc8c8bc93de829416eacf579f1207a8fbf861" +checksum = "d9b20ed30f105399776b9c883e68e536ef602a16ae6f596d2c473591d6ad64c6" dependencies = [ "proc-macro2", "quote", @@ -4351,9 +4346,9 @@ dependencies = [ [[package]] name = "pin-project-lite" -version = "0.2.16" +version = "0.2.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3b3cff922bd51709b605d9ead9aa71031d81447142d828eb4a6eba76fe619f9b" +checksum = "a89322df9ebe1c1578d689c92318e070967d1042b512afbe49518723f4e6d5cd" [[package]] name = "pin-utils" @@ -4363,9 +4358,9 @@ checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" [[package]] name = "piper" -version = "0.2.4" +version = "0.2.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "96c8c490f422ef9a4efd2cb5b42b76c8613d7e7dfc1caf667b8a3350a5acc066" +checksum = "c835479a4443ded371d6c535cbfd8d31ad92c5d23ae9770a61bc155e4992a3c1" dependencies = [ "atomic-waker", "fastrand", @@ -4378,6 +4373,12 @@ version = "0.3.32" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7edddbd0b52d732b21ad9a5fab5c704c14cd949e5e9a1ec5929a24fded1b904c" +[[package]] +name = "plain" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b4596b6d070b27117e987119b4dac604f3c58cfb0b191112e24771b2faeac1a6" + [[package]] name = "plotters" version = "0.3.7" @@ -4563,7 +4564,7 @@ dependencies = [ "quinn-udp", "rustc-hash", "rustls", - "socket2 0.5.10", + "socket2 0.6.3", "thiserror 2.0.18", "tokio", "tracing", @@ -4600,16 +4601,16 @@ dependencies = [ "cfg_aliases", "libc", "once_cell", - "socket2 0.5.10", + "socket2 0.6.3", "tracing", - "windows-sys 0.52.0", + "windows-sys 0.60.2", ] [[package]] name = "quote" -version = "1.0.44" +version = "1.0.45" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "21b2ebcf727b7760c461f091f9f0f539b77b8e87f2fd88131e7f1b433b3cece4" +checksum = "41f2619966050689382d2b44f664f4bc593e129785a36d6ee376ddf37259b924" dependencies = [ "proc-macro2", ] @@ -4620,6 +4621,12 @@ version = "5.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "69cdb34c158ceb288df11e18b4bd39de994f6657d83847bdffdbd7f346754b0f" +[[package]] +name = "r-efi" +version = "6.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f8dcc9c7d52a811697d2151c701e0d08956f92b0e24136cf4cf27b57a6a0d9bf" + [[package]] name = "radix_trie" version = "0.3.0" @@ -4720,9 +4727,9 @@ dependencies = [ [[package]] name = "redox_syscall" -version = "0.7.1" +version = "0.7.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "35985aa610addc02e24fc232012c86fd11f14111180f902b67e2d5331f8ebf2b" +checksum = "6ce70a74e890531977d37e532c34d45e9055d2409ed08ddba14529471ed0be16" dependencies = [ "bitflags 2.11.0", ] @@ -4809,9 +4816,9 @@ dependencies = [ [[package]] name = "regex-syntax" -version = "0.8.9" +version = "0.8.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a96887878f22d7bad8a3b6dc5b7440e0ada9a245242924394987b21cf2210a4c" +checksum = "dc897dd8d9e8bd1ed8cdad82b5966c3e0ecae09fb1907d58efaa013543185d0a" [[package]] name = "regress" @@ -4963,18 +4970,18 @@ dependencies = [ [[package]] name = "rolldown-file-id" -version = "0.2.5" +version = "0.2.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "77087e8de5a5a65ea239ed3a5b182dfc27807a8fca4d0c2c0e693eb528b322b7" +checksum = "502849309ebc019ffc0b96b34ad5ba583e90577d306df9f352215f2ae44b0f1d" dependencies = [ "windows-sys 0.61.2", ] [[package]] name = "rolldown-notify" -version = "10.1.0" +version = "10.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e8bf250d410b79487a6d054e6bd16ec08dddd2998f5f5e6291867a35066cfc37" +checksum = "db2e631ba93bdea8ea34dd3faf92e8a7e37390473411e20c10babfe2dbcdba09" dependencies = [ "bitflags 2.11.0", "inotify", @@ -4991,9 +4998,9 @@ dependencies = [ [[package]] name = "rolldown-notify-debouncer-full" -version = "0.7.4" +version = "0.7.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7141151f3eb9d0869f9fff744ce728f45a0db9c54fe3178e4f60c3c682035083" +checksum = "02edf9ebd50a6b072b96ddb655b5854b777f9cc93096e4d51aba8ade93a83bce" dependencies = [ "rolldown-file-id", "rolldown-notify", @@ -5794,14 +5801,14 @@ dependencies = [ "errno", "libc", "linux-raw-sys", - "windows-sys 0.52.0", + "windows-sys 0.61.2", ] [[package]] name = "rustls" -version = "0.23.36" +version = "0.23.37" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c665f33d38cea657d9614f766881e4d510e0eda4239891eea56b4cadcf01801b" +checksum = "758025cb5fccfd3bc2fd74708fd4682be41d99e5dff73c377c0646c6012c73a4" dependencies = [ "once_cell", "ring", @@ -5946,7 +5953,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5b55fb86dfd3a2f5f76ea78310a88f96c4ea21a3031f8d212443d56123fd0521" dependencies = [ "libc", - "windows-sys 0.52.0", + "windows-sys 0.61.2", ] [[package]] @@ -6276,12 +6283,12 @@ dependencies = [ [[package]] name = "socket2" -version = "0.6.2" +version = "0.6.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "86f4aa3ad99f2088c990dfa82d367e19cb29268ed67c574d10d0a4bfe71f07e0" +checksum = "3a766e1110788c36f4fa1c2b71b387a7815aa65f88ce0229841826633d93723e" dependencies = [ "libc", - "windows-sys 0.60.2", + "windows-sys 0.61.2", ] [[package]] @@ -6450,10 +6457,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "82a72c767771b47409d2345987fda8628641887d5466101319899796367354a0" dependencies = [ "fastrand", - "getrandom 0.4.1", + "getrandom 0.4.2", "once_cell", "rustix", - "windows-sys 0.52.0", + "windows-sys 0.61.2", ] [[package]] @@ -6650,9 +6657,9 @@ checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" [[package]] name = "tokio" -version = "1.49.0" +version = "1.50.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "72a2903cd7736441aac9df9d7688bd0ce48edccaadf181c3b90be801e81d3d86" +checksum = "27ad5e34374e03cfffefc301becb44e9dc3c17584f414349ebe29ed26661822d" dependencies = [ "bytes", "libc", @@ -6660,16 +6667,16 @@ dependencies = [ "parking_lot", "pin-project-lite", "signal-hook-registry", - "socket2 0.6.2", + "socket2 0.6.3", "tokio-macros", "windows-sys 0.61.2", ] [[package]] name = "tokio-macros" -version = "2.6.0" +version = "2.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "af407857209536a95c8e56f8231ef2c2e2aff839b22e07a1ffcbc617e9db9fa5" +checksum = "5c55a2eff8b69ce66c84f85e1da1c233edc36ceb85a2058d11b0d6a3c7e7569c" dependencies = [ "proc-macro2", "quote", @@ -6841,9 +6848,9 @@ dependencies = [ [[package]] name = "tree-sitter" -version = "0.26.5" +version = "0.26.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "12987371f54efc9b9306a20dc87ed5aaee9f320c8a8b115e28515c412b2efe39" +checksum = "13f456d2108c3fef07342ba4689a8503ec1fb5beed245e2b9be93096ef394848" dependencies = [ "cc", "regex", @@ -7050,11 +7057,11 @@ checksum = "06abde3611657adf66d383f00b093d7faecc7fa57071cce2578660c9f1010821" [[package]] name = "uuid" -version = "1.21.0" +version = "1.22.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b672338555252d43fd2240c714dc444b8c6fb0a5c5335e65a07bba7742735ddb" +checksum = "a68d3c8f01c0cfa54a75291d83601161799e4a89a39e0929f4b0354d88757a37" dependencies = [ - "getrandom 0.4.1", + "getrandom 0.4.2", "js-sys", "wasm-bindgen", ] @@ -7553,9 +7560,9 @@ dependencies = [ [[package]] name = "wasm-bindgen" -version = "0.2.112" +version = "0.2.114" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "05d7d0fce354c88b7982aec4400b3e7fcf723c32737cef571bd165f7613557ee" +checksum = "6532f9a5c1ece3798cb1c2cfdba640b9b3ba884f5db45973a6f442510a87d38e" dependencies = [ "cfg-if", "once_cell", @@ -7566,9 +7573,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-futures" -version = "0.4.62" +version = "0.4.64" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ee85afca410ac4abba5b584b12e77ea225db6ee5471d0aebaae0861166f9378a" +checksum = "e9c5522b3a28661442748e09d40924dfb9ca614b21c00d3fd135720e48b67db8" dependencies = [ "cfg-if", "futures-util", @@ -7580,9 +7587,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro" -version = "0.2.112" +version = "0.2.114" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "55839b71ba921e4f75b674cb16f843f4b1f3b26ddfcb3454de1cf65cc021ec0f" +checksum = "18a2d50fcf105fb33bb15f00e7a77b772945a2ee45dcf454961fd843e74c18e6" dependencies = [ "quote", "wasm-bindgen-macro-support", @@ -7590,9 +7597,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro-support" -version = "0.2.112" +version = "0.2.114" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "caf2e969c2d60ff52e7e98b7392ff1588bffdd1ccd4769eba27222fd3d621571" +checksum = "03ce4caeaac547cdf713d280eda22a730824dd11e6b8c3ca9e42247b25c631e3" dependencies = [ "bumpalo", "proc-macro2", @@ -7603,9 +7610,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-shared" -version = "0.2.112" +version = "0.2.114" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0861f0dcdf46ea819407495634953cdcc8a8c7215ab799a7a7ce366be71c7b30" +checksum = "75a326b8c223ee17883a4251907455a2431acc2791c98c26279376490c378c16" dependencies = [ "unicode-ident", ] @@ -7689,9 +7696,9 @@ dependencies = [ [[package]] name = "web-sys" -version = "0.3.89" +version = "0.3.91" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "10053fbf9a374174094915bbce141e87a6bf32ecd9a002980db4b638405e8962" +checksum = "854ba17bb104abfb26ba36da9729addc7ce7f06f5c0f90f3c391f8461cca21f9" dependencies = [ "js-sys", "wasm-bindgen", @@ -7718,14 +7725,12 @@ dependencies = [ [[package]] name = "which" -version = "8.0.0" +version = "8.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d3fabb953106c3c8eea8306e4393700d7657561cb43122571b172bbfb7c7ba1d" +checksum = "81995fafaaaf6ae47a7d0cc83c67caf92aeb7e5331650ae6ff856f7c0c60c459" dependencies = [ - "env_home", - "rustix", + "libc", "tracing", - "winsafe 0.0.19", ] [[package]] @@ -7765,7 +7770,7 @@ version = "0.1.11" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c2a7b1c03c876122aa43f3020e6c3c3ee5c05081c9a00739faf7503aeba10d22" dependencies = [ - "windows-sys 0.52.0", + "windows-sys 0.61.2", ] [[package]] @@ -8092,12 +8097,6 @@ version = "0.53.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d6bbff5f0aada427a1e5a6da5f1f98158182f26556f345ac9e04d36d0ebed650" -[[package]] -name = "winsafe" -version = "0.0.19" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d135d17ab770252ad95e9a872d365cf3090e3be864a34ab46f48555993efc904" - [[package]] name = "winsafe" version = "0.0.24" @@ -8245,18 +8244,18 @@ dependencies = [ [[package]] name = "zerocopy" -version = "0.8.39" +version = "0.8.41" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "db6d35d663eadb6c932438e763b262fe1a70987f9ae936e60158176d710cae4a" +checksum = "96e13bc581734df6250836c59a5f44f3c57db9f9acb9dc8e3eaabdaf6170254d" dependencies = [ "zerocopy-derive", ] [[package]] name = "zerocopy-derive" -version = "0.8.39" +version = "0.8.41" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4122cd3169e94605190e77839c9a40d40ed048d305bfdc146e7df40ab0f3e517" +checksum = "3545ea9e86d12ab9bba9fcd99b54c1556fd3199007def5a03c375623d05fac1c" dependencies = [ "proc-macro2", "quote", @@ -8367,9 +8366,9 @@ dependencies = [ [[package]] name = "zlib-rs" -version = "0.6.2" +version = "0.6.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c745c48e1007337ed136dc99df34128b9faa6ed542d80a1c673cf55a6d7236c8" +checksum = "3be3d40e40a133f9c916ee3f9f4fa2d9d63435b5fbe1bfc6d9dae0aa0ada1513" [[package]] name = "zmij" diff --git a/crates/vite_global_cli/src/help.rs b/crates/vite_global_cli/src/help.rs index 45eb2be8fa..e3cc30d6ff 100644 --- a/crates/vite_global_cli/src/help.rs +++ b/crates/vite_global_cli/src/help.rs @@ -722,8 +722,6 @@ fn delegated_help_doc(command: &str) -> Option { row("--fix", "Auto-fix format and lint issues"), row("--no-fmt", "Skip format check"), row("--no-lint", "Skip lint check"), - row("--no-type-aware", "Disable type-aware linting"), - row("--no-type-check", "Disable TypeScript type checking"), row("-h, --help", "Print help"), ], ), diff --git a/crates/vite_migration/src/package.rs b/crates/vite_migration/src/package.rs index 969aa1eedd..988a5a09b9 100644 --- a/crates/vite_migration/src/package.rs +++ b/crates/vite_migration/src/package.rs @@ -26,7 +26,13 @@ fn rewrite_script(script: &str, rules: &[RuleConfig]) -> String { let result = ast_grep::apply_loaded_rules(&preprocessed, rules); // Step 3: Replace cross-env marker back with "cross-env " (only if we replaced it) - if has_cross_env { result.replace(CROSS_ENV_MARKER, CROSS_ENV_REPLACEMENT) } else { result } + let result = if has_cross_env { + result.replace(CROSS_ENV_MARKER, CROSS_ENV_REPLACEMENT) + } else { + result + }; + + result } /// Transform all script strings in a JSON object using the provided function. diff --git a/packages/cli/binding/src/cli.rs b/packages/cli/binding/src/cli.rs index 47f4e0c48f..6e2ac6ade5 100644 --- a/packages/cli/binding/src/cli.rs +++ b/packages/cli/binding/src/cli.rs @@ -115,12 +115,6 @@ pub enum SynthesizableSubcommand { /// Skip lint check #[arg(long = "no-lint")] no_lint: bool, - /// Disable type-aware linting - #[arg(long = "no-type-aware")] - no_type_aware: bool, - /// Disable TypeScript type checking - #[arg(long = "no-type-check")] - no_type_check: bool, /// File paths to check (passed through to fmt and lint) #[arg(trailing_var_arg = true)] paths: Vec, @@ -1040,14 +1034,7 @@ async fn execute_direct_subcommand( let cwd_arc: Arc = cwd.clone().into(); let status = match subcommand { - SynthesizableSubcommand::Check { - fix, - no_fmt, - no_lint, - no_type_aware, - no_type_check, - paths, - } => { + SynthesizableSubcommand::Check { fix, no_fmt, no_lint, paths } => { if no_fmt && no_lint { output::error("No checks enabled"); print_summary_line( @@ -1140,13 +1127,6 @@ async fn execute_direct_subcommand( if fix { args.push("--fix".to_string()); } - if !no_type_aware { - args.push("--type-aware".to_string()); - // --type-check requires --type-aware as prerequisite - if !no_type_check { - args.push("--type-check".to_string()); - } - } if has_paths { args.extend(paths.iter().cloned()); } @@ -1171,18 +1151,7 @@ async fn execute_direct_subcommand( match analyze_lint_output(&combined_output) { Some(Ok(success)) => { - let type_checks_enabled = !no_type_aware && !no_type_check; - let issue_label = if type_checks_enabled { - if fix { - "Found no warnings, lint errors, or type errors" - } else { - "Found no warnings, lint errors, or type errors" - } - } else if fix { - "Found no warnings or lint errors" - } else { - "Found no warnings or lint errors" - }; + let issue_label = "Found no warnings, lint errors, or type errors"; let message = format!( "{issue_label} in {}", diff --git a/packages/cli/snap-tests-global/migration-auto-create-vite-config/snap.txt b/packages/cli/snap-tests-global/migration-auto-create-vite-config/snap.txt index 316422498c..f519850f31 100644 --- a/packages/cli/snap-tests-global/migration-auto-create-vite-config/snap.txt +++ b/packages/cli/snap-tests-global/migration-auto-create-vite-config/snap.txt @@ -37,6 +37,10 @@ export default defineConfig({ lint: { "rules": { "no-unused-vars": "error" + }, + "options": { + "typeAware": true, + "typeCheck": true } }, }); diff --git a/packages/cli/snap-tests-global/migration-eslint-lint-staged/snap.txt b/packages/cli/snap-tests-global/migration-eslint-lint-staged/snap.txt index 09ef3c84e9..bdc538c238 100644 --- a/packages/cli/snap-tests-global/migration-eslint-lint-staged/snap.txt +++ b/packages/cli/snap-tests-global/migration-eslint-lint-staged/snap.txt @@ -70,6 +70,10 @@ export default defineConfig({ }, "rules": { "no-unused-vars": "error" + }, + "options": { + "typeAware": true, + "typeCheck": true } }, staged: { diff --git a/packages/cli/snap-tests-global/migration-eslint-lintstagedrc/snap.txt b/packages/cli/snap-tests-global/migration-eslint-lintstagedrc/snap.txt index 1958c762d9..956a6e0ac3 100644 --- a/packages/cli/snap-tests-global/migration-eslint-lintstagedrc/snap.txt +++ b/packages/cli/snap-tests-global/migration-eslint-lintstagedrc/snap.txt @@ -75,6 +75,10 @@ export default defineConfig({ }, "rules": { "no-unused-vars": "error" + }, + "options": { + "typeAware": true, + "typeCheck": true } }, staged: { diff --git a/packages/cli/snap-tests-global/migration-eslint-rerun-dual-config/snap.txt b/packages/cli/snap-tests-global/migration-eslint-rerun-dual-config/snap.txt index 7a3eb92862..289f685d12 100644 --- a/packages/cli/snap-tests-global/migration-eslint-rerun-dual-config/snap.txt +++ b/packages/cli/snap-tests-global/migration-eslint-rerun-dual-config/snap.txt @@ -60,6 +60,10 @@ export default defineConfig({ }, "rules": { "no-unused-vars": "error" + }, + "options": { + "typeAware": true, + "typeCheck": true } }, diff --git a/packages/cli/snap-tests-global/migration-eslint-rerun-mjs/snap.txt b/packages/cli/snap-tests-global/migration-eslint-rerun-mjs/snap.txt index 3af8be2395..6843a1a07f 100644 --- a/packages/cli/snap-tests-global/migration-eslint-rerun-mjs/snap.txt +++ b/packages/cli/snap-tests-global/migration-eslint-rerun-mjs/snap.txt @@ -53,6 +53,10 @@ export default defineConfig({ }, "rules": { "no-unused-vars": "error" + }, + "options": { + "typeAware": true, + "typeCheck": true } }, diff --git a/packages/cli/snap-tests-global/migration-eslint-rerun/snap.txt b/packages/cli/snap-tests-global/migration-eslint-rerun/snap.txt index 1b2f7d7779..298e8b87ff 100644 --- a/packages/cli/snap-tests-global/migration-eslint-rerun/snap.txt +++ b/packages/cli/snap-tests-global/migration-eslint-rerun/snap.txt @@ -55,6 +55,10 @@ export default defineConfig({ }, "rules": { "no-unused-vars": "error" + }, + "options": { + "typeAware": true, + "typeCheck": true } }, diff --git a/packages/cli/snap-tests-global/migration-eslint/snap.txt b/packages/cli/snap-tests-global/migration-eslint/snap.txt index 54119c171a..43d3fc9e12 100644 --- a/packages/cli/snap-tests-global/migration-eslint/snap.txt +++ b/packages/cli/snap-tests-global/migration-eslint/snap.txt @@ -79,6 +79,10 @@ export default defineConfig({ }, "rules": { "no-unused-vars": "error" + }, + "options": { + "typeAware": true, + "typeCheck": true } }, }); diff --git a/packages/cli/snap-tests-global/migration-merge-vite-config-js/snap.txt b/packages/cli/snap-tests-global/migration-merge-vite-config-js/snap.txt index 289b6efc30..c3d9a18ed9 100644 --- a/packages/cli/snap-tests-global/migration-merge-vite-config-js/snap.txt +++ b/packages/cli/snap-tests-global/migration-merge-vite-config-js/snap.txt @@ -26,6 +26,10 @@ export default { lint: { "rules": { "no-unused-vars": "error" + }, + "options": { + "typeAware": true, + "typeCheck": true } }, plugins: [react()], diff --git a/packages/cli/snap-tests-global/migration-merge-vite-config-ts/snap.txt b/packages/cli/snap-tests-global/migration-merge-vite-config-ts/snap.txt index 6bc099e69a..e2d1e1c5fe 100644 --- a/packages/cli/snap-tests-global/migration-merge-vite-config-ts/snap.txt +++ b/packages/cli/snap-tests-global/migration-merge-vite-config-ts/snap.txt @@ -43,6 +43,10 @@ export default defineConfig({ lint: { "rules": { "no-unused-vars": "error" + }, + "options": { + "typeAware": true, + "typeCheck": true } }, plugins: [react()], diff --git a/packages/cli/snap-tests-global/migration-monorepo-pnpm/snap.txt b/packages/cli/snap-tests-global/migration-monorepo-pnpm/snap.txt index 00718ad2d3..d3b762bf25 100644 --- a/packages/cli/snap-tests-global/migration-monorepo-pnpm/snap.txt +++ b/packages/cli/snap-tests-global/migration-monorepo-pnpm/snap.txt @@ -42,6 +42,10 @@ export default defineConfig({ lint: { "rules": { "no-unused-vars": "error" + }, + "options": { + "typeAware": true, + "typeCheck": true } }, plugins: [react()], @@ -175,6 +179,10 @@ export default defineConfig({ lint: { "rules": { "no-unused-vars": "warn" + }, + "options": { + "typeAware": true, + "typeCheck": true } }, diff --git a/packages/cli/snap-tests-global/migration-monorepo-yarn4/snap.txt b/packages/cli/snap-tests-global/migration-monorepo-yarn4/snap.txt index a8c8bc0952..bb468848b6 100644 --- a/packages/cli/snap-tests-global/migration-monorepo-yarn4/snap.txt +++ b/packages/cli/snap-tests-global/migration-monorepo-yarn4/snap.txt @@ -29,6 +29,10 @@ export default defineConfig({ lint: { "rules": { "no-unused-vars": "error" + }, + "options": { + "typeAware": true, + "typeCheck": true } }, plugins: [react()], diff --git a/packages/cli/snap-tests-global/new-vite-monorepo/snap.txt b/packages/cli/snap-tests-global/new-vite-monorepo/snap.txt index 05785964e0..4672910f34 100644 --- a/packages/cli/snap-tests-global/new-vite-monorepo/snap.txt +++ b/packages/cli/snap-tests-global/new-vite-monorepo/snap.txt @@ -16,7 +16,7 @@ vite.config.ts "private": true, "type": "module", "scripts": { - "ready": "vp fmt && vp lint --type-aware && vp run test -r && vp run build -r", + "ready": "vp fmt && vp lint && vp run test -r && vp run build -r", "dev": "vp run website#dev", "prepare": "vp config" }, @@ -126,7 +126,7 @@ vite.config.ts "private": true, "type": "module", "scripts": { - "ready": "vp fmt && vp lint --type-aware && vp run test -r && vp run build -r", + "ready": "vp fmt && vp lint && vp run test -r && vp run build -r", "dev": "vp run website#dev", "prepare": "vp config" }, diff --git a/packages/cli/snap-tests/check-no-type-aware/package.json b/packages/cli/snap-tests/check-no-type-aware/package.json deleted file mode 100644 index 985f7824d2..0000000000 --- a/packages/cli/snap-tests/check-no-type-aware/package.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "name": "check-no-type-aware", - "version": "0.0.0", - "private": true -} diff --git a/packages/cli/snap-tests/check-no-type-aware/snap.txt b/packages/cli/snap-tests/check-no-type-aware/snap.txt deleted file mode 100644 index 5908ef2739..0000000000 --- a/packages/cli/snap-tests/check-no-type-aware/snap.txt +++ /dev/null @@ -1,3 +0,0 @@ -> vp check --no-type-aware -pass: All 3 files are correctly formatted (ms, threads) -pass: Found no warnings or lint errors in 1 file (ms, threads) diff --git a/packages/cli/snap-tests/check-no-type-aware/src/index.js b/packages/cli/snap-tests/check-no-type-aware/src/index.js deleted file mode 100644 index 13305bd3e9..0000000000 --- a/packages/cli/snap-tests/check-no-type-aware/src/index.js +++ /dev/null @@ -1,5 +0,0 @@ -function hello() { - return "hello"; -} - -export { hello }; diff --git a/packages/cli/snap-tests/check-no-type-aware/steps.json b/packages/cli/snap-tests/check-no-type-aware/steps.json deleted file mode 100644 index e5c768e88a..0000000000 --- a/packages/cli/snap-tests/check-no-type-aware/steps.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "env": { - "VITE_DISABLE_AUTO_INSTALL": "1" - }, - "commands": ["vp check --no-type-aware"] -} diff --git a/packages/cli/snap-tests/check-no-type-check/package.json b/packages/cli/snap-tests/check-no-type-check/package.json deleted file mode 100644 index fb6ed410df..0000000000 --- a/packages/cli/snap-tests/check-no-type-check/package.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "name": "check-no-type-check", - "version": "0.0.0", - "private": true -} diff --git a/packages/cli/snap-tests/check-no-type-check/snap.txt b/packages/cli/snap-tests/check-no-type-check/snap.txt deleted file mode 100644 index 39c437a51b..0000000000 --- a/packages/cli/snap-tests/check-no-type-check/snap.txt +++ /dev/null @@ -1,3 +0,0 @@ -> vp check --no-type-check -pass: All 3 files are correctly formatted (ms, threads) -pass: Found no warnings or lint errors in 1 file (ms, threads) diff --git a/packages/cli/snap-tests/check-no-type-check/src/index.js b/packages/cli/snap-tests/check-no-type-check/src/index.js deleted file mode 100644 index 13305bd3e9..0000000000 --- a/packages/cli/snap-tests/check-no-type-check/src/index.js +++ /dev/null @@ -1,5 +0,0 @@ -function hello() { - return "hello"; -} - -export { hello }; diff --git a/packages/cli/snap-tests/check-no-type-check/steps.json b/packages/cli/snap-tests/check-no-type-check/steps.json deleted file mode 100644 index 72bf1dbb08..0000000000 --- a/packages/cli/snap-tests/check-no-type-check/steps.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "env": { - "VITE_DISABLE_AUTO_INSTALL": "1" - }, - "commands": ["vp check --no-type-check"] -} diff --git a/packages/cli/snap-tests/command-init-inline-config/snap.txt b/packages/cli/snap-tests/command-init-inline-config/snap.txt index 58b03512cc..27afbb52b1 100644 --- a/packages/cli/snap-tests/command-init-inline-config/snap.txt +++ b/packages/cli/snap-tests/command-init-inline-config/snap.txt @@ -5,7 +5,7 @@ Added 'lint' to 'vite.config.ts'. import { defineConfig } from "vite-plus"; export default defineConfig({ - lint: {}, + lint: { options: { typeAware: true, typeCheck: true } }, }); > cat .oxlintrc.json && exit 1 || true # check .oxlintrc.json is removed diff --git a/packages/cli/src/__tests__/init-config.spec.ts b/packages/cli/src/__tests__/init-config.spec.ts index 1dabd3046a..989f5a2dc6 100644 --- a/packages/cli/src/__tests__/init-config.spec.ts +++ b/packages/cli/src/__tests__/init-config.spec.ts @@ -30,7 +30,7 @@ describe('applyToolInitConfigToViteConfig', () => { ).resolves.toEqual({ handled: false }); }); - it('creates vite.config.ts and writes lint: {} for vp lint --init', async () => { + it('creates vite.config.ts and writes lint config with options for vp lint --init', async () => { const projectPath = createTempDir(); fs.writeFileSync( path.join(projectPath, '.oxlintrc.json'), @@ -54,11 +54,12 @@ describe('applyToolInitConfigToViteConfig', () => { const content = fs.readFileSync(viteConfigPath, 'utf8'); expect(content).toContain('import { defineConfig } from'); expect(content).toContain('vite-plus'); - expect(content).toContain('lint: {}'); + expect(content).toContain('typeAware'); + expect(content).toContain('typeCheck'); expect(fs.existsSync(path.join(projectPath, '.oxlintrc.json'))).toBe(false); }); - it('ignores generated lint init defaults and still writes lint: {}', async () => { + it('ignores generated lint init defaults and still writes lint with options', async () => { const projectPath = createTempDir(); fs.writeFileSync( path.join(projectPath, '.oxlintrc.json'), @@ -112,7 +113,8 @@ describe('applyToolInitConfigToViteConfig', () => { expect(result.action).toBe('added'); const content = fs.readFileSync(path.join(projectPath, 'vite.config.ts'), 'utf8'); - expect(content).toContain('lint: {}'); + expect(content).toContain('typeAware'); + expect(content).toContain('typeCheck'); expect(content).not.toContain('jsx-a11y'); expect(content).not.toContain('ignorePatterns'); }); diff --git a/packages/cli/src/init-config.ts b/packages/cli/src/init-config.ts index 6b823f8f0e..8e9eab233c 100644 --- a/packages/cli/src/init-config.ts +++ b/packages/cli/src/init-config.ts @@ -229,7 +229,10 @@ export async function applyToolInitConfigToViteConfig( if (spec.configKey === 'lint' && hasTriggerFlag(args, ['--init'])) { const lintInitConfigPath = path.join(projectPath, '.vite-plus-lint-init.oxlintrc.json'); - fs.writeFileSync(lintInitConfigPath, '{}'); + fs.writeFileSync( + lintInitConfigPath, + JSON.stringify({ options: { typeAware: true, typeCheck: true } }), + ); const mergeResult = mergeJsonConfig(viteConfigPath, lintInitConfigPath, spec.configKey); if (!mergeResult.updated) { diff --git a/packages/cli/src/migration/migrator.ts b/packages/cli/src/migration/migrator.ts index 7c182c1098..e13b45aa21 100644 --- a/packages/cli/src/migration/migrator.ts +++ b/packages/cli/src/migration/migrator.ts @@ -928,6 +928,19 @@ export function mergeViteConfigFiles(projectPath: string, silent = false): void } const viteConfig = ensureViteConfig(projectPath, configs, silent); if (configs.oxlintConfig) { + // Inject options.typeAware and options.typeCheck defaults before merging + const fullOxlintPath = path.join(projectPath, configs.oxlintConfig); + const oxlintJson = JSON.parse(fs.readFileSync(fullOxlintPath, 'utf8')); + if (!oxlintJson.options) { + oxlintJson.options = {}; + } + if (oxlintJson.options.typeAware === undefined) { + oxlintJson.options.typeAware = true; + } + if (oxlintJson.options.typeCheck === undefined) { + oxlintJson.options.typeCheck = true; + } + fs.writeFileSync(fullOxlintPath, JSON.stringify(oxlintJson, null, 2)); // merge oxlint config into vite.config.ts mergeAndRemoveJsonConfig(projectPath, viteConfig, configs.oxlintConfig, 'lint', silent); } diff --git a/packages/cli/src/utils/editor.ts b/packages/cli/src/utils/editor.ts index d987b09e5c..5eff268f37 100644 --- a/packages/cli/src/utils/editor.ts +++ b/packages/cli/src/utils/editor.ts @@ -15,7 +15,6 @@ const VSCODE_SETTINGS = { 'editor.codeActionsOnSave': { 'source.fixAll.oxc': 'explicit', }, - 'oxc.typeAware': true, } as const; const VSCODE_EXTENSIONS = { diff --git a/packages/cli/templates/monorepo/package.json b/packages/cli/templates/monorepo/package.json index ecff78a487..2dca034224 100644 --- a/packages/cli/templates/monorepo/package.json +++ b/packages/cli/templates/monorepo/package.json @@ -9,7 +9,7 @@ ], "type": "module", "scripts": { - "ready": "vp fmt && vp lint --type-aware && vp run test -r && vp run build -r", + "ready": "vp fmt && vp lint && vp run test -r && vp run build -r", "dev": "vp run website#dev" }, "engines": { diff --git a/vite.config.ts b/vite.config.ts index 9530c700cd..e03e6fef87 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -2,6 +2,10 @@ import { defineConfig } from 'vite-plus'; export default defineConfig({ lint: { + options: { + typeAware: true, + typeCheck: true, + }, plugins: ['unicorn', 'typescript', 'oxc'], categories: { correctness: 'error', From 6237268f38e002e1c810196bd0bce0e16837986f Mon Sep 17 00:00:00 2001 From: MK Date: Mon, 9 Mar 2026 21:30:03 +0800 Subject: [PATCH 2/8] fix(migrate): skip typeAware/typeCheck when tsconfig.json has baseUrl oxlint's TypeScript checker (tsgolint) does not support baseUrl in tsconfig.json, causing lint failures after migration. Guard both migration and lint --init paths to omit typeAware/typeCheck defaults when baseUrl is present. --- .../steps.json | 1 + .../migration-baseurl-tsconfig/package.json | 5 ++ .../migration-baseurl-tsconfig/snap.txt | 47 +++++++++++++++++++ .../migration-baseurl-tsconfig/steps.json | 8 ++++ .../migration-baseurl-tsconfig/tsconfig.json | 7 +++ packages/cli/src/init-config.ts | 10 ++-- packages/cli/src/migration/migrator.ts | 15 +++--- packages/cli/src/utils/json.ts | 17 +++++++ packages/cli/src/utils/prompts.ts | 2 +- rfcs/migration-command.md | 6 +++ 10 files changed, 107 insertions(+), 11 deletions(-) create mode 100644 packages/cli/snap-tests-global/migration-baseurl-tsconfig/package.json create mode 100644 packages/cli/snap-tests-global/migration-baseurl-tsconfig/snap.txt create mode 100644 packages/cli/snap-tests-global/migration-baseurl-tsconfig/steps.json create mode 100644 packages/cli/snap-tests-global/migration-baseurl-tsconfig/tsconfig.json diff --git a/packages/cli/snap-tests-global/create-from-nonworkspace-subdir/steps.json b/packages/cli/snap-tests-global/create-from-nonworkspace-subdir/steps.json index bbbd6abbd6..53e7424b4d 100644 --- a/packages/cli/snap-tests-global/create-from-nonworkspace-subdir/steps.json +++ b/packages/cli/snap-tests-global/create-from-nonworkspace-subdir/steps.json @@ -1,4 +1,5 @@ { + "ignoredPlatforms": ["win32"], "commands": [ { "command": "cd scripts && vp create --no-interactive vite:application # from non-monorepo subdir", diff --git a/packages/cli/snap-tests-global/migration-baseurl-tsconfig/package.json b/packages/cli/snap-tests-global/migration-baseurl-tsconfig/package.json new file mode 100644 index 0000000000..46b0108c4a --- /dev/null +++ b/packages/cli/snap-tests-global/migration-baseurl-tsconfig/package.json @@ -0,0 +1,5 @@ +{ + "devDependencies": { + "oxlint": "1" + } +} diff --git a/packages/cli/snap-tests-global/migration-baseurl-tsconfig/snap.txt b/packages/cli/snap-tests-global/migration-baseurl-tsconfig/snap.txt new file mode 100644 index 0000000000..62f79b2e8b --- /dev/null +++ b/packages/cli/snap-tests-global/migration-baseurl-tsconfig/snap.txt @@ -0,0 +1,47 @@ +> vp migrate --no-interactive # migration should skip typeAware/typeCheck when tsconfig has baseUrl +VITE+ - The Unified Toolchain for the Web + + +Using default package manager: pnpm + +pnpm@latest installing... + +pnpm@ installed + +✔ Created vite.config.ts in vite.config.ts + +✔ Merged staged config into vite.config.ts + +Wrote agent instructions to AGENTS.md +✔ Migration completed! + + +> cat vite.config.ts # check vite.config.ts — should NOT have typeAware or typeCheck +import { defineConfig } from 'vite-plus'; + +export default defineConfig({ + staged: { + "*": "vp check --fix" + }, + +}); + +> cat .oxlintrc.json && exit 1 || true # check .oxlintrc.json is removed +cat: .oxlintrc.json: No such file or directory + +> cat package.json # check package.json +{ + "devDependencies": { + "vite-plus": "latest" + }, + "pnpm": { + "overrides": { + "vite": "npm:@voidzero-dev/vite-plus-core@latest", + "vitest": "npm:@voidzero-dev/vite-plus-test@latest" + } + }, + "packageManager": "pnpm@", + "scripts": { + "prepare": "vp config" + } +} diff --git a/packages/cli/snap-tests-global/migration-baseurl-tsconfig/steps.json b/packages/cli/snap-tests-global/migration-baseurl-tsconfig/steps.json new file mode 100644 index 0000000000..d19d972551 --- /dev/null +++ b/packages/cli/snap-tests-global/migration-baseurl-tsconfig/steps.json @@ -0,0 +1,8 @@ +{ + "commands": [ + "vp migrate --no-interactive # migration should skip typeAware/typeCheck when tsconfig has baseUrl", + "cat vite.config.ts # check vite.config.ts — should NOT have typeAware or typeCheck", + "cat .oxlintrc.json && exit 1 || true # check .oxlintrc.json is removed", + "cat package.json # check package.json" + ] +} diff --git a/packages/cli/snap-tests-global/migration-baseurl-tsconfig/tsconfig.json b/packages/cli/snap-tests-global/migration-baseurl-tsconfig/tsconfig.json new file mode 100644 index 0000000000..4ac1954ddb --- /dev/null +++ b/packages/cli/snap-tests-global/migration-baseurl-tsconfig/tsconfig.json @@ -0,0 +1,7 @@ +{ + "compilerOptions": { + "target": "ES2023", + "module": "NodeNext", + "baseUrl": "." + } +} diff --git a/packages/cli/src/init-config.ts b/packages/cli/src/init-config.ts index 8e9eab233c..517d00d250 100644 --- a/packages/cli/src/init-config.ts +++ b/packages/cli/src/init-config.ts @@ -5,6 +5,7 @@ import { mergeJsonConfig } from '../binding/index.js'; import { fmt as resolveFmt } from './resolve-fmt.js'; import { runCommandSilently } from './utils/command.js'; import { VITE_PLUS_NAME } from './utils/constants.js'; +import { hasBaseUrlInTsconfig } from './utils/json.js'; interface InitCommandSpec { configKey: 'lint' | 'fmt'; @@ -229,10 +230,11 @@ export async function applyToolInitConfigToViteConfig( if (spec.configKey === 'lint' && hasTriggerFlag(args, ['--init'])) { const lintInitConfigPath = path.join(projectPath, '.vite-plus-lint-init.oxlintrc.json'); - fs.writeFileSync( - lintInitConfigPath, - JSON.stringify({ options: { typeAware: true, typeCheck: true } }), - ); + // Skip typeAware/typeCheck when tsconfig.json has baseUrl (unsupported by tsgolint) + const initOptions = hasBaseUrlInTsconfig(projectPath) + ? {} + : { typeAware: true, typeCheck: true }; + fs.writeFileSync(lintInitConfigPath, JSON.stringify({ options: initOptions })); const mergeResult = mergeJsonConfig(viteConfigPath, lintInitConfigPath, spec.configKey); if (!mergeResult.updated) { diff --git a/packages/cli/src/migration/migrator.ts b/packages/cli/src/migration/migrator.ts index e13b45aa21..c94d56557e 100644 --- a/packages/cli/src/migration/migrator.ts +++ b/packages/cli/src/migration/migrator.ts @@ -22,7 +22,7 @@ import { VITE_PLUS_VERSION, resolve, } from '../utils/constants.js'; -import { editJsonFile, isJsonFile, readJsonFile } from '../utils/json.js'; +import { editJsonFile, hasBaseUrlInTsconfig, isJsonFile, readJsonFile } from '../utils/json.js'; import { detectPackageMetadata } from '../utils/package.js'; import { displayRelative, rulesDir } from '../utils/path.js'; import { getSpinner } from '../utils/prompts.js'; @@ -934,11 +934,14 @@ export function mergeViteConfigFiles(projectPath: string, silent = false): void if (!oxlintJson.options) { oxlintJson.options = {}; } - if (oxlintJson.options.typeAware === undefined) { - oxlintJson.options.typeAware = true; - } - if (oxlintJson.options.typeCheck === undefined) { - oxlintJson.options.typeCheck = true; + // Skip typeAware/typeCheck when tsconfig.json has baseUrl (unsupported by tsgolint) + if (!hasBaseUrlInTsconfig(projectPath)) { + if (oxlintJson.options.typeAware === undefined) { + oxlintJson.options.typeAware = true; + } + if (oxlintJson.options.typeCheck === undefined) { + oxlintJson.options.typeCheck = true; + } } fs.writeFileSync(fullOxlintPath, JSON.stringify(oxlintJson, null, 2)); // merge oxlint config into vite.config.ts diff --git a/packages/cli/src/utils/json.ts b/packages/cli/src/utils/json.ts index e9aa7a285b..65d6bb3e80 100644 --- a/packages/cli/src/utils/json.ts +++ b/packages/cli/src/utils/json.ts @@ -1,4 +1,5 @@ import fs from 'node:fs'; +import path from 'node:path'; import detectIndent from 'detect-indent'; import { detectNewline } from 'detect-newline'; @@ -39,3 +40,19 @@ export function isJsonFile(file: string): boolean { return false; } } + +/** + * Check if tsconfig.json has compilerOptions.baseUrl set. + * oxlint's TypeScript checker (tsgolint) does not support baseUrl, + * so typeAware/typeCheck must be disabled when it is present. + */ +export function hasBaseUrlInTsconfig(projectPath: string): boolean { + try { + const tsconfig = readJsonFile<{ compilerOptions?: { baseUrl?: string } }>( + path.join(projectPath, 'tsconfig.json'), + ); + return tsconfig?.compilerOptions?.baseUrl !== undefined; + } catch { + return false; + } +} diff --git a/packages/cli/src/utils/prompts.ts b/packages/cli/src/utils/prompts.ts index 8ebacbaa2b..badac44b96 100644 --- a/packages/cli/src/utils/prompts.ts +++ b/packages/cli/src/utils/prompts.ts @@ -66,7 +66,7 @@ export async function runViteInstall( options?: { silent?: boolean }, ) { // install dependencies on non-CI environment - if (process.env.VITE_PLUS_SKIP_INSTALL || process.env.CI) { + if (process.env.VITE_PLUS_SKIP_INSTALL) { return { durationMs: 0, status: 'skipped' } satisfies CommandRunSummary; } diff --git a/rfcs/migration-command.md b/rfcs/migration-command.md index e01683ecae..b1c234365a 100644 --- a/rfcs/migration-command.md +++ b/rfcs/migration-command.md @@ -243,6 +243,10 @@ export default defineConfig({ // Oxlint configuration lint: { + options: { + typeAware: true, + typeCheck: true, + }, rules: { 'no-unused-vars': 'error', 'no-console': 'warn', @@ -252,6 +256,8 @@ export default defineConfig({ }); ``` +> **Note**: If `tsconfig.json` contains `compilerOptions.baseUrl`, `typeAware` and `typeCheck` are not injected because oxlint's TypeScript checker does not support `baseUrl`. + ### Oxfmt Configuration **Before (.oxfmtrc):** From 56dfed9c8bd97f3ade7d9559f382468cf158e291 Mon Sep 17 00:00:00 2001 From: MK Date: Mon, 9 Mar 2026 22:16:03 +0800 Subject: [PATCH 3/8] fix(migrate): log warning when baseUrl skips typeAware/typeCheck When tsconfig.json has baseUrl and we skip injecting typeAware/typeCheck, log a warning with actionable advice to run `npx @andrewbranch/ts5to6 --fixBaseUrl .` to remove baseUrl. Added warning in both migration and lint --init paths. Updated snap test fixture with .oxlintrc.json to capture the warning output. --- .../command-dlx-no-package-json/steps.json | 1 + .../migration-baseurl-tsconfig/.oxlintrc.json | 5 +++++ .../migration-baseurl-tsconfig/snap.txt | 12 +++++++++++- packages/cli/src/init-config.ts | 11 +++++++---- packages/cli/src/migration/migrator.ts | 3 +++ packages/cli/src/utils/constants.ts | 4 ++++ rfcs/migration-command.md | 2 +- 7 files changed, 32 insertions(+), 6 deletions(-) create mode 100644 packages/cli/snap-tests-global/migration-baseurl-tsconfig/.oxlintrc.json diff --git a/packages/cli/snap-tests-global/command-dlx-no-package-json/steps.json b/packages/cli/snap-tests-global/command-dlx-no-package-json/steps.json index ddf1d511d7..7c590ed4a2 100644 --- a/packages/cli/snap-tests-global/command-dlx-no-package-json/steps.json +++ b/packages/cli/snap-tests-global/command-dlx-no-package-json/steps.json @@ -1,3 +1,4 @@ { + "ignoredPlatforms": ["win32"], "commands": ["vp dlx -s cowsay hello # should work without package.json"] } diff --git a/packages/cli/snap-tests-global/migration-baseurl-tsconfig/.oxlintrc.json b/packages/cli/snap-tests-global/migration-baseurl-tsconfig/.oxlintrc.json new file mode 100644 index 0000000000..0eb0592cdb --- /dev/null +++ b/packages/cli/snap-tests-global/migration-baseurl-tsconfig/.oxlintrc.json @@ -0,0 +1,5 @@ +{ + "rules": { + "no-unused-vars": "error" + } +} diff --git a/packages/cli/snap-tests-global/migration-baseurl-tsconfig/snap.txt b/packages/cli/snap-tests-global/migration-baseurl-tsconfig/snap.txt index 62f79b2e8b..fc1202e277 100644 --- a/packages/cli/snap-tests-global/migration-baseurl-tsconfig/snap.txt +++ b/packages/cli/snap-tests-global/migration-baseurl-tsconfig/snap.txt @@ -10,6 +10,11 @@ pnpm@ installed ✔ Created vite.config.ts in vite.config.ts +Skipped typeAware/typeCheck: tsconfig.json contains baseUrl which is not yet supported by the oxlint type checker. + Run `npx @andrewbranch/ts5to6 --fixBaseUrl .` to remove baseUrl from your tsconfig. + +✔ Merged .oxlintrc.json into vite.config.ts + ✔ Merged staged config into vite.config.ts Wrote agent instructions to AGENTS.md @@ -23,7 +28,12 @@ export default defineConfig({ staged: { "*": "vp check --fix" }, - + lint: { + "rules": { + "no-unused-vars": "error" + }, + "options": {} + }, }); > cat .oxlintrc.json && exit 1 || true # check .oxlintrc.json is removed diff --git a/packages/cli/src/init-config.ts b/packages/cli/src/init-config.ts index 517d00d250..117d917e8b 100644 --- a/packages/cli/src/init-config.ts +++ b/packages/cli/src/init-config.ts @@ -4,8 +4,9 @@ import path from 'node:path'; import { mergeJsonConfig } from '../binding/index.js'; import { fmt as resolveFmt } from './resolve-fmt.js'; import { runCommandSilently } from './utils/command.js'; -import { VITE_PLUS_NAME } from './utils/constants.js'; +import { BASEURL_TSCONFIG_WARNING, VITE_PLUS_NAME } from './utils/constants.js'; import { hasBaseUrlInTsconfig } from './utils/json.js'; +import { warnMsg } from './utils/terminal.js'; interface InitCommandSpec { configKey: 'lint' | 'fmt'; @@ -231,9 +232,11 @@ export async function applyToolInitConfigToViteConfig( if (spec.configKey === 'lint' && hasTriggerFlag(args, ['--init'])) { const lintInitConfigPath = path.join(projectPath, '.vite-plus-lint-init.oxlintrc.json'); // Skip typeAware/typeCheck when tsconfig.json has baseUrl (unsupported by tsgolint) - const initOptions = hasBaseUrlInTsconfig(projectPath) - ? {} - : { typeAware: true, typeCheck: true }; + const hasBaseUrl = hasBaseUrlInTsconfig(projectPath); + const initOptions = hasBaseUrl ? {} : { typeAware: true, typeCheck: true }; + if (hasBaseUrl) { + warnMsg(BASEURL_TSCONFIG_WARNING); + } fs.writeFileSync(lintInitConfigPath, JSON.stringify({ options: initOptions })); const mergeResult = mergeJsonConfig(viteConfigPath, lintInitConfigPath, spec.configKey); diff --git a/packages/cli/src/migration/migrator.ts b/packages/cli/src/migration/migrator.ts index c94d56557e..08d53ee9b7 100644 --- a/packages/cli/src/migration/migrator.ts +++ b/packages/cli/src/migration/migrator.ts @@ -17,6 +17,7 @@ import { import { PackageManager, type WorkspaceInfo, type WorkspacePackage } from '../types/index.js'; import { runCommandSilently } from '../utils/command.js'; import { + BASEURL_TSCONFIG_WARNING, VITE_PLUS_NAME, VITE_PLUS_OVERRIDE_PACKAGES, VITE_PLUS_VERSION, @@ -942,6 +943,8 @@ export function mergeViteConfigFiles(projectPath: string, silent = false): void if (oxlintJson.options.typeCheck === undefined) { oxlintJson.options.typeCheck = true; } + } else if (!silent) { + prompts.log.warn(BASEURL_TSCONFIG_WARNING); } fs.writeFileSync(fullOxlintPath, JSON.stringify(oxlintJson, null, 2)); // merge oxlint config into vite.config.ts diff --git a/packages/cli/src/utils/constants.ts b/packages/cli/src/utils/constants.ts index a93b90afd8..4adf161730 100644 --- a/packages/cli/src/utils/constants.ts +++ b/packages/cli/src/utils/constants.ts @@ -19,6 +19,10 @@ export function resolve(path: string) { }); } +export const BASEURL_TSCONFIG_WARNING = + 'Skipped typeAware/typeCheck: tsconfig.json contains baseUrl which is not yet supported by the oxlint type checker.\n' + + ' Run `npx @andrewbranch/ts5to6 --fixBaseUrl .` to remove baseUrl from your tsconfig.'; + export const DEFAULT_ENVS = { // Provide Node.js runtime information for oxfmt's telemetry/compatibility JS_RUNTIME_VERSION: process.versions.node, diff --git a/rfcs/migration-command.md b/rfcs/migration-command.md index b1c234365a..0254510328 100644 --- a/rfcs/migration-command.md +++ b/rfcs/migration-command.md @@ -256,7 +256,7 @@ export default defineConfig({ }); ``` -> **Note**: If `tsconfig.json` contains `compilerOptions.baseUrl`, `typeAware` and `typeCheck` are not injected because oxlint's TypeScript checker does not support `baseUrl`. +> **Note**: If `tsconfig.json` contains `compilerOptions.baseUrl`, `typeAware` and `typeCheck` are not injected because oxlint's TypeScript checker does not yet support `baseUrl`. Run `npx @andrewbranch/ts5to6 --fixBaseUrl .` to migrate away from `baseUrl`. ### Oxfmt Configuration From a9e8be2588ea4aef409dd2c5c00f297eff674711 Mon Sep 17 00:00:00 2001 From: MK Date: Mon, 9 Mar 2026 23:04:35 +0800 Subject: [PATCH 4/8] fix: lazy-import init-config to avoid missing devDependency in published package The static import of init-config.js in bin.ts transitively loads detect-indent (a devDependency), causing ERR_MODULE_NOT_FOUND when vite-plus is installed as a dependency. Change to dynamic import so it's only loaded for local commands that actually need it. Fixes frm-stack E2E test failure. --- packages/cli/src/bin.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/packages/cli/src/bin.ts b/packages/cli/src/bin.ts index 9f9f520216..6dc48811b2 100644 --- a/packages/cli/src/bin.ts +++ b/packages/cli/src/bin.ts @@ -13,7 +13,6 @@ import path from 'node:path'; import { run } from '../binding/index.js'; -import { applyToolInitConfigToViteConfig, inspectInitCommand } from './init-config.js'; import { doc } from './resolve-doc.js'; import { fmt } from './resolve-fmt.js'; import { lint } from './resolve-lint.js'; @@ -56,6 +55,9 @@ if (command === 'create') { await import('./global/staged.js'); } else { // All other commands — delegate to Rust core via NAPI binding + // Lazy-import init-config to avoid loading devDependencies (detect-indent, etc.) + // that aren't available when the package is installed as a dependency. + const { applyToolInitConfigToViteConfig, inspectInitCommand } = await import('./init-config.js'); try { const initInspection = inspectInitCommand(command, args.slice(1)); if ( From 8c2003f3cb1fc5823bfb4740e3ae156cf3c75801 Mon Sep 17 00:00:00 2001 From: MK Date: Mon, 9 Mar 2026 23:24:36 +0800 Subject: [PATCH 5/8] fix: move detect-indent/detect-newline to dependencies MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The previous lazy-import fix was insufficient — init-config.js is still loaded for all non-global commands. The actual root cause is that these packages were in devDependencies but are imported at runtime by tsc-compiled dist/utils/json.js. Move them to dependencies so they're available when vite-plus is installed in other projects. --- packages/cli/package.json | 4 ++-- packages/cli/src/bin.ts | 4 +--- pnpm-lock.yaml | 12 ++++++------ 3 files changed, 9 insertions(+), 11 deletions(-) diff --git a/packages/cli/package.json b/packages/cli/package.json index 338af24071..23c1592dee 100644 --- a/packages/cli/package.json +++ b/packages/cli/package.json @@ -309,6 +309,8 @@ "@voidzero-dev/vite-plus-test": "workspace:*", "cac": "catalog:", "cross-spawn": "catalog:", + "detect-indent": "catalog:", + "detect-newline": "catalog:", "oxfmt": "catalog:", "oxlint": "catalog:", "oxlint-tsgolint": "catalog:", @@ -323,8 +325,6 @@ "@types/validate-npm-package-name": "catalog:", "@voidzero-dev/vite-plus-prompts": "workspace:*", "@voidzero-dev/vite-plus-tools": "workspace:", - "detect-indent": "catalog:", - "detect-newline": "catalog:", "glob": "catalog:", "lint-staged": "catalog:", "minimatch": "catalog:", diff --git a/packages/cli/src/bin.ts b/packages/cli/src/bin.ts index 6dc48811b2..9f9f520216 100644 --- a/packages/cli/src/bin.ts +++ b/packages/cli/src/bin.ts @@ -13,6 +13,7 @@ import path from 'node:path'; import { run } from '../binding/index.js'; +import { applyToolInitConfigToViteConfig, inspectInitCommand } from './init-config.js'; import { doc } from './resolve-doc.js'; import { fmt } from './resolve-fmt.js'; import { lint } from './resolve-lint.js'; @@ -55,9 +56,6 @@ if (command === 'create') { await import('./global/staged.js'); } else { // All other commands — delegate to Rust core via NAPI binding - // Lazy-import init-config to avoid loading devDependencies (detect-indent, etc.) - // that aren't available when the package is installed as a dependency. - const { applyToolInitConfigToViteConfig, inspectInitCommand } = await import('./init-config.js'); try { const initInspection = inspectInitCommand(command, args.slice(1)); if ( diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index ee6502c466..01bf0ea4f9 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -371,6 +371,12 @@ importers: cross-spawn: specifier: 'catalog:' version: 7.0.6 + detect-indent: + specifier: 'catalog:' + version: 7.0.2 + detect-newline: + specifier: 'catalog:' + version: 4.0.1 oxfmt: specifier: 'catalog:' version: 0.36.0 @@ -408,12 +414,6 @@ importers: '@voidzero-dev/vite-plus-tools': specifier: 'workspace:' version: link:../tools - detect-indent: - specifier: 'catalog:' - version: 7.0.2 - detect-newline: - specifier: 'catalog:' - version: 4.0.1 glob: specifier: 'catalog:' version: 13.0.0 From 44ca36f39382014ae3a41a5945d19d9c3b9b3f75 Mon Sep 17 00:00:00 2001 From: MK Date: Mon, 9 Mar 2026 23:46:15 +0800 Subject: [PATCH 6/8] fix: extract hasBaseUrlInTsconfig to utils/tsconfig.ts to avoid detect-indent dependency chain MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Move hasBaseUrlInTsconfig from utils/json.ts (which imports detect-indent) to a new utils/tsconfig.ts that uses only Node.js builtins. This breaks the transitive dependency chain from init-config.ts → json.ts → detect-indent, allowing detect-indent/detect-newline to remain devDependencies since they are only used by rolldown-bundled global CLI code. --- packages/cli/package.json | 4 ++-- packages/cli/src/init-config.ts | 2 +- packages/cli/src/migration/migrator.ts | 3 ++- packages/cli/src/utils/json.ts | 17 ----------------- packages/cli/src/utils/tsconfig.ts | 18 ++++++++++++++++++ pnpm-lock.yaml | 12 ++++++------ 6 files changed, 29 insertions(+), 27 deletions(-) create mode 100644 packages/cli/src/utils/tsconfig.ts diff --git a/packages/cli/package.json b/packages/cli/package.json index 23c1592dee..338af24071 100644 --- a/packages/cli/package.json +++ b/packages/cli/package.json @@ -309,8 +309,6 @@ "@voidzero-dev/vite-plus-test": "workspace:*", "cac": "catalog:", "cross-spawn": "catalog:", - "detect-indent": "catalog:", - "detect-newline": "catalog:", "oxfmt": "catalog:", "oxlint": "catalog:", "oxlint-tsgolint": "catalog:", @@ -325,6 +323,8 @@ "@types/validate-npm-package-name": "catalog:", "@voidzero-dev/vite-plus-prompts": "workspace:*", "@voidzero-dev/vite-plus-tools": "workspace:", + "detect-indent": "catalog:", + "detect-newline": "catalog:", "glob": "catalog:", "lint-staged": "catalog:", "minimatch": "catalog:", diff --git a/packages/cli/src/init-config.ts b/packages/cli/src/init-config.ts index 117d917e8b..a2d9d13053 100644 --- a/packages/cli/src/init-config.ts +++ b/packages/cli/src/init-config.ts @@ -5,8 +5,8 @@ import { mergeJsonConfig } from '../binding/index.js'; import { fmt as resolveFmt } from './resolve-fmt.js'; import { runCommandSilently } from './utils/command.js'; import { BASEURL_TSCONFIG_WARNING, VITE_PLUS_NAME } from './utils/constants.js'; -import { hasBaseUrlInTsconfig } from './utils/json.js'; import { warnMsg } from './utils/terminal.js'; +import { hasBaseUrlInTsconfig } from './utils/tsconfig.js'; interface InitCommandSpec { configKey: 'lint' | 'fmt'; diff --git a/packages/cli/src/migration/migrator.ts b/packages/cli/src/migration/migrator.ts index 08d53ee9b7..02cd5624f9 100644 --- a/packages/cli/src/migration/migrator.ts +++ b/packages/cli/src/migration/migrator.ts @@ -23,10 +23,11 @@ import { VITE_PLUS_VERSION, resolve, } from '../utils/constants.js'; -import { editJsonFile, hasBaseUrlInTsconfig, isJsonFile, readJsonFile } from '../utils/json.js'; +import { editJsonFile, isJsonFile, readJsonFile } from '../utils/json.js'; import { detectPackageMetadata } from '../utils/package.js'; import { displayRelative, rulesDir } from '../utils/path.js'; import { getSpinner } from '../utils/prompts.js'; +import { hasBaseUrlInTsconfig } from '../utils/tsconfig.js'; import { editYamlFile, scalarString, type YamlDocument } from '../utils/yaml.js'; import { detectConfigs, type ConfigFiles } from './detector.js'; diff --git a/packages/cli/src/utils/json.ts b/packages/cli/src/utils/json.ts index 65d6bb3e80..e9aa7a285b 100644 --- a/packages/cli/src/utils/json.ts +++ b/packages/cli/src/utils/json.ts @@ -1,5 +1,4 @@ import fs from 'node:fs'; -import path from 'node:path'; import detectIndent from 'detect-indent'; import { detectNewline } from 'detect-newline'; @@ -40,19 +39,3 @@ export function isJsonFile(file: string): boolean { return false; } } - -/** - * Check if tsconfig.json has compilerOptions.baseUrl set. - * oxlint's TypeScript checker (tsgolint) does not support baseUrl, - * so typeAware/typeCheck must be disabled when it is present. - */ -export function hasBaseUrlInTsconfig(projectPath: string): boolean { - try { - const tsconfig = readJsonFile<{ compilerOptions?: { baseUrl?: string } }>( - path.join(projectPath, 'tsconfig.json'), - ); - return tsconfig?.compilerOptions?.baseUrl !== undefined; - } catch { - return false; - } -} diff --git a/packages/cli/src/utils/tsconfig.ts b/packages/cli/src/utils/tsconfig.ts new file mode 100644 index 0000000000..f540b8ad97 --- /dev/null +++ b/packages/cli/src/utils/tsconfig.ts @@ -0,0 +1,18 @@ +import fs from 'node:fs'; +import path from 'node:path'; + +/** + * Check if tsconfig.json has compilerOptions.baseUrl set. + * oxlint's TypeScript checker (tsgolint) does not support baseUrl, + * so typeAware/typeCheck must be disabled when it is present. + */ +export function hasBaseUrlInTsconfig(projectPath: string): boolean { + try { + const tsconfig = JSON.parse( + fs.readFileSync(path.join(projectPath, 'tsconfig.json'), 'utf-8'), + ) as { compilerOptions?: { baseUrl?: string } }; + return tsconfig?.compilerOptions?.baseUrl !== undefined; + } catch { + return false; + } +} diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 01bf0ea4f9..ee6502c466 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -371,12 +371,6 @@ importers: cross-spawn: specifier: 'catalog:' version: 7.0.6 - detect-indent: - specifier: 'catalog:' - version: 7.0.2 - detect-newline: - specifier: 'catalog:' - version: 4.0.1 oxfmt: specifier: 'catalog:' version: 0.36.0 @@ -414,6 +408,12 @@ importers: '@voidzero-dev/vite-plus-tools': specifier: 'workspace:' version: link:../tools + detect-indent: + specifier: 'catalog:' + version: 7.0.2 + detect-newline: + specifier: 'catalog:' + version: 4.0.1 glob: specifier: 'catalog:' version: 13.0.0 From 6880f2b15900a9d5366797eac50f2a6d4acbed54 Mon Sep 17 00:00:00 2001 From: MK Date: Tue, 10 Mar 2026 00:23:47 +0800 Subject: [PATCH 7/8] fix(migrate): strip $schema property from JSON configs when merging into vite.config.ts The $schema annotation in .oxlintrc.json/.oxfmtrc.json causes TS2769 type errors when merged into vite.config.ts because it's not part of OxlintConfig/OxfmtConfig types. Strip it before merging. --- crates/vite_migration/src/vite_config.rs | 69 ++++++++++++++++++- .../migration-eslint-lint-staged/snap.txt | 1 - .../migration-eslint-lintstagedrc/snap.txt | 1 - .../snap.txt | 1 - .../migration-eslint-rerun-mjs/snap.txt | 1 - .../migration-eslint-rerun/snap.txt | 1 - .../migration-eslint/snap.txt | 1 - 7 files changed, 67 insertions(+), 8 deletions(-) diff --git a/crates/vite_migration/src/vite_config.rs b/crates/vite_migration/src/vite_config.rs index b206a10e20..1c55ec1ef1 100644 --- a/crates/vite_migration/src/vite_config.rs +++ b/crates/vite_migration/src/vite_config.rs @@ -1,7 +1,8 @@ -use std::path::Path; +use std::{borrow::Cow, path::Path, sync::LazyLock}; use ast_grep_config::{GlobalRules, RuleConfig, from_yaml_string}; use ast_grep_language::{LanguageExt, SupportLang}; +use regex::Regex; use vite_error::Error; use crate::ast_grep; @@ -100,8 +101,11 @@ fn merge_json_config_content( // Check if the config uses a function callback (for informational purposes) let uses_function_callback = check_function_callback(vite_config_content)?; + // Strip "$schema" property — it's a JSON Schema annotation not valid in OxlintConfig + let ts_config = strip_schema_property(ts_config); + // Generate the ast-grep rules with the actual config - let rule_yaml = generate_merge_rule(ts_config, config_key); + let rule_yaml = generate_merge_rule(&ts_config, config_key); // Apply the transformation let (content, updated) = ast_grep::apply_rules(vite_config_content, &rule_yaml)?; @@ -109,6 +113,21 @@ fn merge_json_config_content( Ok(MergeResult { content, updated, uses_function_callback }) } +/// Regex to match `"$schema": "..."` lines (with optional trailing comma). +static RE_SCHEMA: LazyLock = + LazyLock::new(|| Regex::new(r#"(?m)^\s*"\$schema"\s*:\s*"[^"]*"\s*,?\s*\n"#).unwrap()); + +/// Strip the `"$schema"` property from a JSON/JSONC config string. +/// +/// JSON config files (`.oxlintrc.json`, `.oxfmtrc.json`) often contain a +/// `"$schema"` annotation that is meaningful only for editor validation. +/// When the JSON content is embedded into `vite.config.ts`, the `$schema` +/// property causes a TypeScript type error because it is not part of +/// `OxlintConfig` / `OxfmtConfig`. +fn strip_schema_property(config: &str) -> Cow<'_, str> { + RE_SCHEMA.replace_all(config, "") +} + /// Check if the vite config uses a function callback pattern fn check_function_callback(vite_config_content: &str) -> Result { // Match both sync and async arrow functions @@ -870,6 +889,52 @@ export default defineConfig({ ); } + #[test] + fn test_strip_schema_property() { + // With trailing comma + let input = r#"{ + "$schema": "https://raw.githubusercontent.com/nicolo-ribaudo/tc39-proposal-json-schema/refs/heads/main/schema.json", + "rules": { + "no-console": "warn" + } +}"#; + let result = strip_schema_property(input); + assert!(!result.contains("$schema")); + assert!(result.contains(r#""no-console": "warn""#)); + + // Without trailing comma + let input = r#"{ + "$schema": "https://example.com/schema.json" +}"#; + let result = strip_schema_property(input); + assert!(!result.contains("$schema")); + + // No $schema - unchanged + let input = r#"{ + "rules": {} +}"#; + assert_eq!(strip_schema_property(input), input); + } + + #[test] + fn test_merge_json_config_content_strips_schema() { + let vite_config = r#"import { defineConfig } from 'vite'; + +export default defineConfig({});"#; + + let oxlint_config = r#"{ + "$schema": "https://raw.githubusercontent.com/nicolo-ribaudo/tc39-proposal-json-schema/refs/heads/main/schema.json", + "rules": { + "no-console": "warn" + } +}"#; + + let result = merge_json_config_content(vite_config, oxlint_config, "lint").unwrap(); + assert!(result.updated); + assert!(!result.content.contains("$schema")); + assert!(result.content.contains(r#""no-console": "warn""#)); + } + #[test] fn test_indent_multiline() { // Single line - no change diff --git a/packages/cli/snap-tests-global/migration-eslint-lint-staged/snap.txt b/packages/cli/snap-tests-global/migration-eslint-lint-staged/snap.txt index bdc538c238..8f5e62e049 100644 --- a/packages/cli/snap-tests-global/migration-eslint-lint-staged/snap.txt +++ b/packages/cli/snap-tests-global/migration-eslint-lint-staged/snap.txt @@ -64,7 +64,6 @@ export default defineConfig({ "categories": { "correctness": "warn" }, - "$schema": "./node_modules/oxlint/configuration_schema.json", "env": { "builtin": true }, diff --git a/packages/cli/snap-tests-global/migration-eslint-lintstagedrc/snap.txt b/packages/cli/snap-tests-global/migration-eslint-lintstagedrc/snap.txt index 956a6e0ac3..6a5b953471 100644 --- a/packages/cli/snap-tests-global/migration-eslint-lintstagedrc/snap.txt +++ b/packages/cli/snap-tests-global/migration-eslint-lintstagedrc/snap.txt @@ -69,7 +69,6 @@ export default defineConfig({ "categories": { "correctness": "warn" }, - "$schema": "./node_modules/oxlint/configuration_schema.json", "env": { "builtin": true }, diff --git a/packages/cli/snap-tests-global/migration-eslint-rerun-dual-config/snap.txt b/packages/cli/snap-tests-global/migration-eslint-rerun-dual-config/snap.txt index 289f685d12..8c06c1c326 100644 --- a/packages/cli/snap-tests-global/migration-eslint-rerun-dual-config/snap.txt +++ b/packages/cli/snap-tests-global/migration-eslint-rerun-dual-config/snap.txt @@ -54,7 +54,6 @@ export default defineConfig({ "categories": { "correctness": "warn" }, - "$schema": "./node_modules/oxlint/configuration_schema.json", "env": { "builtin": true }, diff --git a/packages/cli/snap-tests-global/migration-eslint-rerun-mjs/snap.txt b/packages/cli/snap-tests-global/migration-eslint-rerun-mjs/snap.txt index 6843a1a07f..0d2377cfc1 100644 --- a/packages/cli/snap-tests-global/migration-eslint-rerun-mjs/snap.txt +++ b/packages/cli/snap-tests-global/migration-eslint-rerun-mjs/snap.txt @@ -47,7 +47,6 @@ export default defineConfig({ "categories": { "correctness": "warn" }, - "$schema": "./node_modules/oxlint/configuration_schema.json", "env": { "builtin": true }, diff --git a/packages/cli/snap-tests-global/migration-eslint-rerun/snap.txt b/packages/cli/snap-tests-global/migration-eslint-rerun/snap.txt index 298e8b87ff..7675f69cf5 100644 --- a/packages/cli/snap-tests-global/migration-eslint-rerun/snap.txt +++ b/packages/cli/snap-tests-global/migration-eslint-rerun/snap.txt @@ -49,7 +49,6 @@ export default defineConfig({ "categories": { "correctness": "warn" }, - "$schema": "./node_modules/oxlint/configuration_schema.json", "env": { "builtin": true }, diff --git a/packages/cli/snap-tests-global/migration-eslint/snap.txt b/packages/cli/snap-tests-global/migration-eslint/snap.txt index 43d3fc9e12..3f3f9273ea 100644 --- a/packages/cli/snap-tests-global/migration-eslint/snap.txt +++ b/packages/cli/snap-tests-global/migration-eslint/snap.txt @@ -73,7 +73,6 @@ export default defineConfig({ "categories": { "correctness": "warn" }, - "$schema": "./node_modules/oxlint/configuration_schema.json", "env": { "builtin": true }, From 69220fb0a2f74b4ed9b571d657b4dc906f9306a3 Mon Sep 17 00:00:00 2001 From: MK Date: Tue, 10 Mar 2026 00:27:21 +0800 Subject: [PATCH 8/8] chore: update vue-mini e2e project hash to latest --- ecosystem-ci/repo.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ecosystem-ci/repo.json b/ecosystem-ci/repo.json index 1d75c08536..7a64745f08 100644 --- a/ecosystem-ci/repo.json +++ b/ecosystem-ci/repo.json @@ -28,7 +28,7 @@ "vue-mini": { "repository": "https://github.com/vue-mini/vue-mini.git", "branch": "master", - "hash": "c51332662993dde44f665822bdea94cd0abf368b" + "hash": "23df6ba49e29d3ea909ef55874f59b973916d177" }, "vite-plugin-react": { "repository": "https://github.com/vitejs/vite-plugin-react.git",