Skip to content

vp migrate parse VSCode settings as JSON without comments #1002

@liangmiQwQ

Description

@liangmiQwQ

Describe the bug

For example, we have such a .vscode/settings.json and we run vp migrate while choose to merge VSCode config

{
  // THERE IS A COMMENT
  "git.enableCommitSigning": true,
}

It is actually a JSONC file but Vite+ will use JSON.parse to parse it and break the migration

Perhaps we need to change parser to jsonc when migrating editor's config, and it can bring jsonc-parser as a new dependency (It seems already availible in catalog but never use)

Reproduction

https://github.com/liangmiQwQ/vp-migrate-vscode

Steps to reproduce

Run pnpm run try in the repo

System Info

VITE+ - The Unified Toolchain for the Web

Environment:
  Version      24.14.0
  Source       default
  Source Path  /Users/liangmi/.vite-plus/config.json

Tool Paths:
  node  /Users/liangmi/.vite-plus/js_runtime/node/24.14.0/bin/node
  npm   /Users/liangmi/.vite-plus/js_runtime/node/24.14.0/bin/npm
  npx   /Users/liangmi/.vite-plus/js_runtime/node/24.14.0/bin/npx

Used Package Manager

pnpm

Logs

Expected property name or '}' in JSON at position 4 (line 2 column 3)
SyntaxError: Expected property name or '}' in JSON at position 4 (line 2 column 3)
    at JSON.parse (<anonymous>)
    at readJsonFile (file:///Users/liangmi/code/vite-plus/packages/cli/dist/global/json-Dglt0cMI.js:125:14)
    at mergeAndWriteEditorConfig (file:///Users/liangmi/code/vite-plus/packages/cli/dist/global/workspace-CHw21TZm.js:2825:45)
    at writeEditorConfigs (file:///Users/liangmi/code/vite-plus/packages/cli/dist/global/workspace-CHw21TZm.js:2816:36)
    at async executeMigrationPlan (file:///Users/liangmi/code/vite-plus/packages/cli/dist/global/migrate.js:409:2)
    at async main (file:///Users/liangmi/code/vite-plus/packages/cli/dist/global/migrate.js:489:17)
■ Canceled (0s)

Validations

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Priority

    None yet

    Effort

    None yet

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions