ITADN

vp create svelte generates config where vp check reports $props as no-undef

#1967Opencrypt0box 创建于 2026-06-28
pending triage
C
crypt0boxcommented
### Describe the bug `vp create svelte` can generate a project that fails `vp check` immediately. The failure comes from the migrated Oxlint config preserving core `no-undef` for `.svelte` files. Valid Svelte 5 rune syntax such as `$props()` is reported as undefined: ```txt eslint(no-undef): '$props' is not defined. ``` This appears to be a migration/config compatibility issue rather than an application code issue. ### Current workaround Manually disable `no-undef` for `.svelte` files in the generated `vite.config.ts`: ```ts { files: ["*.svelte", "**/*.svelte"], rules: { "no-inner-declarations": "off", "no-self-assign": "off", "no-undef": "off", }, jsPlugins: ["eslint-plugin-svelte"], } ``` After this change, the `$props()` errors are no longer reported. ### Proposed fix When Vite+ migrates the ESLint config generated by `sv create --add eslint` into the `lint` block in `vite.config.ts`, normalize Svelte overrides so core `no-undef` is disabled for `.svelte` files. For example, during the migrated Oxlint config sanitization step, if an override targets `*.svelte` / `**/*.svelte`, add: ```ts rules: { "no-undef": "off", } ``` This does not attempt to add full Svelte template linting support to Oxlint. It only prevents migrated core `no-undef` from flagging valid Svelte 5 rune globals such as `$props()` while Oxlint’s Svelte support is still partial. One related observation: current `sv create --add eslint --types ts` [disables `no-undef` globally](https://github.com/sveltejs/cli/blob/ab775f536a69804945cf250a0791fe59b0533543/packages/sv/src/addons/eslint.ts#L69) for TypeScript projects, following typescript-eslint guidance. So another possible fix would be to preserve that top-level `no-undef: "off"` during migration. However, the minimal compatibility fix is to disable `no-undef` for migrated `.svelte` overrides. --- This may be small enough that you might decide not to add a Vite+ migration-layer workaround and instead address it as part of broader Svelte support in Oxlint / `@oxlint/migrate`. That would be understandable. If you think this compatibility normalization belongs in Vite+, I would be happy to open a PR. Also, thanks for building Vite+. I really like this tool. ### Reproduction https://github.com/crypt0box/vite-plus-svelte-eslint ### Steps to reproduce 1. Create a Svelte project with Vite+: ```sh vp create svelte ``` Choose TypeScript and ESLint. 2. Install dependencies if needed: ```sh vp install ``` 3. Run checks: ```sh vp check ``` 4. Observe that `vp check` fails on generated Svelte files: ```txt error: Lint or type issues found x eslint(no-undef): '$props' is not defined. ,-[src/routes/+layout.svelte:4:21] 3 | 4 | let { children } = $props(); : ^^^^^^ 5 | </script> `---- x eslint(no-undef): '$props' is not defined. ,-[src/lib/vitest-examples/Welcome.svelte:4:49] 3 | 4 | let { host = 'SvelteKit', guest = 'Vitest' } = $props(); : ^^^^^^ 5 | </script> `---- ``` The generated `vite.config.ts` contains a top-level `no-undef: "error"` and a Svelte override that does not disable `no-undef`: ```ts lint: { rules: { "no-undef": "error", // ... }, overrides: [ { files: ["*.svelte", "**/*.svelte"], rules: { "no-inner-declarations": "off", "no-self-assign": "off", }, jsPlugins: ["eslint-plugin-svelte"], }, ], } ``` ### System Info ```shell vp v0.2.1 Local vite-plus: vite-plus v0.2.1 Tools: vite v8.0.16 rolldown v1.1.1 vitest v4.1.9 oxfmt v0.55.0 oxlint v1.70.0 oxlint-tsgolint v0.23.0 tsdown v0.22.3 Environment: Package manager pnpm v11.9.0 Node.js v24.18.0 ``` ### Used Package Manager pnpm ### Validations - [x] Read the [Contributing Guidelines](https://github.com/voidzero-dev/vite-plus/blob/main/CONTRIBUTING.md). - [x] Check that there isn't [already an issue](https://github.com/voidzero-dev/vite-plus/issues) for the same bug. - [x] Confirm this is a Vite+ issue and not an upstream issue (Vite, Vitest, tsdown, Rolldown, or Oxc). - [x] The provided reproduction is a [minimal reproducible example](https://stackoverflow.com/help/minimal-reproducible-example).
0 条评论