-
Notifications
You must be signed in to change notification settings - Fork 44
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
@const variables used in style directives give "no-unused-vars" #174
Comments
Note that I'm not seeing the same issue when used in a class directive. Also this is version 3.4.1. |
Was about to create an issue about the same problem, though I was using <script>
const images = [
{ src: 'https://placeimg.com/500/500/any', width: '250px' },
{ src: 'https://placeimg.com/500/500/any', width: '250px' },
{ src: 'https://placeimg.com/500/500/any', width: '250px' },
];
</script>
{#each images as image}
{@const { src, width } = image}
<img {src} style:width alt />
{/each} |
To note that this does not give errors: <script>
const images = [
{ src: 'https://placeimg.com/500/500/any', w: '250px' },
{ src: 'https://placeimg.com/500/500/any', w: '250px' },
{ src: 'https://placeimg.com/500/500/any', w: '250px' }
];
</script>
{#each images as image}
{@const { src, w } = image}
<img {src} style:width={w} alt />
{/each} So the problem seems to be with the shorthand |
<script>
const numbers = [1, 2, 3, 4];
</script>
{#each numbers as number}
{@const tag = number === 1 ? 'h1' : 'p'}
<svelte:element this={tag}>{number}</svelte:element>
{/each} Error message: Workaround:
|
I have code like this:
But eslint with eslint-plugin-svelte3 report no-unused-vars, apparently not accounting for "left" and "width" being referenced in the style directives.
The text was updated successfully, but these errors were encountered: