Open
Description
Before You File a Bug Report Please Confirm You Have Done The Following...
- I'm using eslint-plugin-svelte. (
*.svelte
file linting does not work with the parser alone. You should also use eslint-plugin-svelte with it.)I'm sure the problem is a parser problem. (If you are not sure, search for the issue in eslint-plugin-svelte repo and open the issue in eslint-plugin-svelte repo if there is no solution.I have tried restarting my IDE and the issue persists.I have updated to the latest version of the packages.
What version of ESLint are you using?
9.19.0
What version of eslint-plugin-svelte
and svelte-eslint-parser
are you using?
- svelte-eslint-parser@0.43.0
- eslint-plugin-svelte@3.0.0-next.16
What did you do?
Configuration
export default ts.config([
...ts.configs.recommendedTypeChecked,
...sveltePlugin.configs.recommended,
{
files: ["**/*.svelte"],
languageOptions: {
parserOptions: {
extraFileExtensions: [".svelte"],
parser: ts.parser,
project: "./tsconfig.json",
},
},
rules: {
"@typescript-eslint/no-confusing-void-expression": "warn",
},
},
]);
{#snippet text(string: string)}
{string}
{/snippet}
{@render text('Whoa')}
What did you expect to happen?
No errors.
What actually happened?
Placing a void expression inside another expression is forbidden. Move it to its own statement instead.
eslint(@typescript-eslint/no-confusing-void-expression)
Link to GitHub Repo with Minimal Reproducible Example
https://github.com/lishaduck/sv-esl-prs-repro
Additional comments
sonarjs/no-use-of-empty-return-value
also fails, so it's not just a types issue.
Activity
baseballyama commentedon Feb 23, 2025
@ota-meshi
Reading the
typescript-eslint
source code, it appears that the following line always reportsSvelteRenderTag
. Since this issue cannot be resolved with parser tweaks, I believe the only option is to implement an extended rule ineslint-plugin-svelte
. What do you think?https://github.com/typescript-eslint/typescript-eslint/blob/662e62baca4ed8910d09b24db64ec3535e53863d/packages/eslint-plugin/src/rules/no-confusing-void-expression.ts#L360-L362
@typescript-eslint/no-confusing-void-expression
crashes with{@render mySnippet()}
sveltejs/eslint-plugin-svelte#1097 as a duplicate of this issueota-meshi commentedon Mar 5, 2025
Yeah, I think we need an extended rule, as you say.