Skip to content

@typescript-eslint/no-shadow maybe shouldn't trigger on Snippets? #908

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Closed
marekdedic opened this issue Nov 8, 2024 · 2 comments
Closed
Labels
enhancement New feature or request
Milestone

Comments

@marekdedic
Copy link
Contributor

Description

Hi, the rule @typescript-eslint/no-shadow now triggers on snippets like this:

<ComponentWithSnippet>
  {#snippet children()}
    <AnotherComponentWithSnippet>
      {#snippet children()}
        Hello!
      {/snippet}
    </AnotherComponentWithSnippet>
  {/snippet}
</ComponentWithSnippet>

This results on an error on the second children function (children' is already declared in the upper scope on line ...). However, this is probably (?) Mostly a false positive - you aren't actually shadowing a meaningful function or variable and you cannot really always control Snippet names (e.g. when they come from a 3rd party library) and you want to use the name children if possible...

Could we change the rule/parsing/...? so that this rule never triggers on snippets? I can't come up with an example where you'd actually want the rule to trigger on snippets, but maybe there is some?

@marekdedic marekdedic added the enhancement New feature or request label Nov 8, 2024
@marekdedic
Copy link
Contributor Author

Hmm, sorry, now I found #871, which is very similar....

@baseballyama
Copy link
Member

Fixed by sveltejs/svelte-eslint-parser#645.
Please try to use svelte-eslint-parser 1.0.0-next.13.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
enhancement New feature or request
Projects
None yet
2 participants