Skip to content

Incorrectly parses Svelte 5 snippets' returns #657

Open
@lishaduck

Description

@lishaduck

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

baseballyama commented on Feb 23, 2025

@baseballyama
Member

@ota-meshi

Reading the typescript-eslint source code, it appears that the following line always reports SvelteRenderTag. Since this issue cannot be resolved with parser tweaks, I believe the only option is to implement an extended rule in eslint-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

ota-meshi

ota-meshi commented on Mar 5, 2025

@ota-meshi
Member

Yeah, I think we need an extended rule, as you say.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @ota-meshi@baseballyama@lishaduck

        Issue actions

          Incorrectly parses Svelte 5 snippets' returns · Issue #657 · sveltejs/svelte-eslint-parser