sveltejs / eslint-plugin-svelte

ESLint plugin for Svelte using AST
https://sveltejs.github.io/eslint-plugin-svelte/
MIT License
277 stars 30 forks source link

Incorrect no-undef and @typescript-eslint/no-unused-vars errors for Svelte 5 Snippets #703

Closed nicksulkers closed 3 months ago

nicksulkers commented 3 months ago

Before You File a Bug Report Please Confirm You Have Done The Following...

What version of ESLint are you using?

8.56.0

What version of eslint-plugin-svelte are you using?

2.36.0-next.4

What did you do?

Configuration ``` /** @type { import("eslint").Linter.Config } */ module.exports = { root: true, extends: [ 'eslint:recommended', 'plugin:@typescript-eslint/recommended', 'plugin:svelte/recommended', 'prettier' ], parser: '@typescript-eslint/parser', plugins: ['@typescript-eslint'], parserOptions: { sourceType: 'module', ecmaVersion: 2020, extraFileExtensions: ['.svelte'] }, env: { browser: true, es2017: true, node: true }, overrides: [ { files: ['*.svelte'], parser: 'svelte-eslint-parser', parserOptions: { parser: '@typescript-eslint/parser' } } ] }; ```
<script lang="ts">
    const mySnippetInDisguise = mySnippet;
</script>

{#snippet mySnippet()}
    <p>Hello World!</p>
{/snippet}

{@render mySnippetInDisguise()}

What did you expect to happen?

No errors.

What actually happened?

ESLint reported two contractory errors:

Link to GitHub Repo with Minimal Reproducible Example

https://github.com/nicksulkers/eslint-svelte5-snippets-bug-repro

Additional comments

My initial assumption is that snippets in Svelte 5 act like hoisted functions. However, it appears that ESLint does not recognize them as such. As a result, when these snippets are utilized within a Githubissues.

  • Githubissues is a development platform for aggregating issues.