Skip to content

Variable defined on a component slot and used on the same element wrongly reported as not defined and not used #356

Closed
@divdavem

Description

@divdavem

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

  • 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?

8.33.0

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

2.15.0

What did you do?

<script lang="ts">
  import MyComponent from "./MyComponent.svelte"
</script>

<MyComponent>
  <span
    slot="something"
    let:myVar
    class:myClass={myVar} />
</MyComponent>

What did you expect to happen?

I expected no eslint error because the myVar variable is actually defined and used.

What actually happened?

I get the following two wrong eslint errors:

8:9: 'myVar' is defined but never used. (no-unused-vars)
9:20: 'myVar' is not defined. (no-undef)

Link to GitHub Repo with Minimal Reproducible Example

https://ota-meshi.github.io/eslint-plugin-svelte/playground/#eJx1Vcty2zgQ/BUVz0FctUeXk0vOue5JlyE4JBHjwQWGshmX/30boEiKlHyS0DMczKOn8VHp0HD1XL0kHc0gJ0u++3GuJJ2rn2d/Ohk3hCin39OvgH+evZzaGNzpXH1/ugG/pwtb4XN19i9Pcyh8jsONT4n3kgby+c/plGwQXJWCY+mN7/LHGbcsz276l+J81JZSAvAr//74KJbP09PPfNM+evWtiqPlVD1/VHM+T/UoErzqKSmZBhT6z7fFpINz+E41JrIWc9kZfVAEE9djp4S6dG/rxdlHpiY45cibYbQkqOpoHgdWbBMr06raBv16FyB7IOc1r4cOSSbLaohh4Cjmsc+IW76OMnlyRqs8BYW/x/KN9xzRAbQ/opDgjwE8vmtHr7MNDfaN5XhwCfUfXI5QSvhdlBuTkO7vUolMJcU13JcO1ghHskd76sHRnMK+LZMKF47RNHc3JgmRFaXJ64NFKHYsmAz516MpkrGYqAKF9V3I0b/68OavGaxtX3O5c8d0kG8BlOk8Ejq6JAaZ0+O2DZHbMp8kcdQyxhysVJUv3LlG/m9EOioMYpz5y0uXSCQaLAg/cp5jabK2JnC0cCmhMQPY4L7+YJ0UabToYRrFMYEURm7NaUrCu8gXsqZRWNPB2DlHDWqUckNUCQyf+dbidO138AXBBMETJIO+zEje2Tzt3B1nUAu/sx4RZ7FqystyZHs2ZNnBxwkzWjHkRCjFc6f+cgwbDgoeXZHyI4wgPdnfrFnPFonBIvOO3xewqFDHcTtDIVldaEPytoO4aQfMmTt2Nce95ao/O+yVp1snazQJl7YsKLvhSuPloHSPdunc63LZ3jhQnsJaG78f2gBJiKTqECyTzzfJ3pLYmQVpQUTpYxi7foUgFoeInQ012QM4v2BH0M/sKo0eVjTiDN2O6q2H0pQ9X2w2oJmhBYFYm3QzM9AJBTRZGL5ohzPveemKaqisUkL1avT8ptLk6mBXJPigBXWAjsbhl5OmYU0Eolr2co1QnJcD+C0hP3WqHo3FA7S6QSEKvXkDUPutmGVhZNseWpUeLVPqqQlvALGPBhU35QnZwmA9UqZkpI1VeOSTqrnNOrFtb9HChtvtgIFwCelGFADF5c2W9aWn2t5AiVq8HMajJdMBxX7S7Xpd4SyEAf55XpCh6xu9ibKlmrf2XkGs2wZdlTlLY9Fh9htRFiP2R/dHcD/KNyOzx6KNk2HbFCTrrUme5txnsuaxhtyoz8//Ab+iZkc=

Additional comments

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions