Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

vp migrate crashes with "Undefined meta var" when a migrated config string contains `$`

未关闭
#3,045 0 条评论 0 个 reaction 已指派 1 人 在 GitHub 查看

维护者通常 1 天内回复

@BenjyLimmy 已经在做这个了。

开始于 2026年10月14日。

  • #3046 来自 @BenjyLimmy —— 未关闭

评估

这个 Issue 还没有评估数据。

描述

bug
Describe the bug

vp migrate crashes when a config value it merges into vite.config.ts contains $ followed by uppercase letters or digits, for example $200 or $FOO.

■  Fail to parse yaml as Rule.
Error: Fail to parse yaml as Rule.
  cause: Error: Undefined meta var `200` used in `fix`.

The crash happens after migration has already deleted eslint.config.mjs and written .oxlintrc.json, so the project is left half-migrated.

It looks like generate_merge_rule in crates/vp_migration/src/vite_config.rs pastes the JSON config text into the ast-grep fix: template, where $NAME and $<digits> are metavariable syntax. Any string value with that shape breaks the rule, for example an ESLint message, an i18n ignore list or a URL with $ in it.

Expected: string values are inserted literally.

I intend to submit a PR for this.

Reproduction

Inline below. It needs three files and no repo.

Steps to reproduce

package.json

{
  "name": "vp-migrate-dollar-repro",
  "private": true,
  "type": "module",
  "packageManager": "[email protected]",
  "devDependencies": {
    "vite": "8.2.2",
    "eslint": "10.8.1"
  }
}

eslint.config.mjs

export default [
  {
    rules: {
      'no-restricted-imports': ['error', {
        paths: [{ name: 'moment', message: 'Use date-fns. moment costs $200 of bundle budget.' }],
      }],
    },
  },
];

vite.config.ts

import { defineConfig } from 'vite';

export default defineConfig({});
git init && git add -A && git commit -m init
pnpm install
pnpm dlx [email protected] vp migrate --no-interactive
git status --porcelain

Result: exit code 1 with the error above. git status shows eslint.config.mjs deleted and .oxlintrc.json untracked. Changing $200 to 200 dollars makes the migration succeed.

System Info
# vp env current: not available, the global vp CLI is not installed (ran through pnpm dlx)
$ pnpm dlx [email protected] vp -V
vp v1.1.0

Local vite-plus:
  vite-plus  v1.1.0

Tools:
  vite             v8.3.3
  rolldown         v1.2.12
  vitest           v5.0.3
  oxfmt            v0.72.0
  oxlint           v1.87.0
  oxlint-tsgolint  v7.0.2003

macOS 26.6.2 arm64, Node v22.23.2, pnpm 10.14.0
Used Package Manager

pnpm

Logs
■  Fail to parse yaml as Rule.
Error: Fail to parse yaml as Rule.
    at mergeAndRemoveJsonConfig (vite-plus/dist/editor-B8tkz7nL.js:9238:17)
  code: 'GenericFailure',
  cause: Error: Undefined meta var `200` used in `fix`.
      at mergeAndRemoveJsonConfig (vite-plus/dist/editor-B8tkz7nL.js:9238:17)
      at mergeViteConfigFiles (vite-plus/dist/editor-B8tkz7nL.js:9184:3)
      at rewriteMonorepoProject (vite-plus/dist/editor-B8tkz7nL.js:9988:2)
      at rewriteRootWorkspacePackageJson (vite-plus/dist/editor-B8tkz7nL.js:7947:2)
      at rewriteMonorepo (vite-plus/dist/editor-B8tkz7nL.js:9949:2)
      at executeMigrationPlan (vite-plus/dist/migration/bin.js:3860:32)
Validations
  • Read the Contributing Guidelines.
  • Check that there isn't already an issue for the same bug.
  • Confirm this is a Vite+ issue and not an upstream issue (Vite, Vitest, tsdown, Rolldown, or Oxc).
  • The provided reproduction is a minimal reproducible example.
主要语言
Rust
星标
6k
派生
274
平均合并
1 天 11 小时
30 天内合并 PR
211

环境准备

在 Codespaces 中打开

在浏览器里用你自己的 GitHub 账号启动这个项目的开发容器。

  • 没有 Dockerfile 或 Docker Compose 文件
  • 没有 Pull Request 模板
  • 阅读贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

voidzero-dev/vite-plus 的其他 Issue

查看 voidzero-dev/vite-plus 的全部 Issue

相似的 Issue

更多 Rust Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。