Last 12 weeks · 44 commits
2 of 6 standards met
Before You File a Bug Report Please Confirm You Have Done The Following... [x] I'm using eslint-plugin-svelte. (.svelte file linting does not work with the parser alone.) [x] I'm sure the problem is a parser problem. (If not sure, open the issue in eslint-plugin-svelte repo instead.) [x] I have tried restarting my IDE and the issue persists. [x] I have updated to the latest version of the packages. What version of ESLint are you using? 10.5.0 What version of eslint-plugin-svelte and svelte-eslint-parser are you using? svelte-eslint-parser@1.8.0 eslint-plugin-svelte@3.20.0 What did you do? Used — the standard Svelte 5 pattern for a reactive template declaration — inside a block whose condition narrows a discriminated union type. Configuration The same declaration without does not error: What did you expect to happen? The expression inside should be type-checked in the same narrowed context as the rest of the branch body. Since the condition narrows to , should be typed as with no ESLint error — the same as when is absent from the declaration. What actually happened? inside is typed as — as if the condition's narrowing was never applied: Isolation testing confirms the bug is specific to : The bug only surfaces in practice with , because that is the tag that requires for reactivity. The legacy tag is inherently non-reactive and does not use , so it is unaffected. Link to GitHub Repo with Minimal Reproducible Example https://github.com/marekdedic/svelte-eslint-parser-derived-repro Additional comments declaration tags were introduced in Svelte 5.56.0, so this is only reachable on very recent Svelte versions. Plain declarations without , and all other runes and function calls tested (, user-defined functions), correctly inherit narrowing. Likely cause: wraps the argument in a function in its generated TypeScript representation, which prevents TypeScript's narrowing (which does not cross function boundaries) from applying. The issue affects any type-aware rule — the root cause is that resolves to type rather than the narrowed . Tested with 5.56.4, 6.0.3, 8.x, Node.js 26.3.1. Disclaimer: issue was investigated and written using LLMs, but verified by a human.
Repository: sveltejs/svelte-eslint-parser. Description: Svelte parser for ESLint Stars: 123, Forks: 29. Primary language: TypeScript. Languages: TypeScript (87.1%), Svelte (8.5%), JavaScript (4.1%), Dockerfile (0.2%), HTML (0.1%). License: MIT. Homepage: https://sveltejs.github.io/svelte-eslint-parser/ Topics: eslint, eslint-custom-parser, eslint-parser, parser, svelte, sveltejs. Latest release: v1.8.0 (3w ago). Open PRs: 19, open issues: 12. Last activity: 21h ago. Community health: 50%. Top contributors: renovate[bot], ota-meshi, github-actions[bot], baseballyama, renovate-bot, marekdedic, arpitjain099, IWANABETHATGUY, 43081j, JounQin and others.