sveltejs / eslint-plugin-svelte3

An ESLint plugin for Svelte v3 components.
MIT License
373 stars 43 forks source link

Index value from {#each} seen as missing-declaration #37

Closed tivac closed 5 years ago

tivac commented 5 years ago

While I know this keyed {#each} is a little silly-looking, it is exposing what I believe is a bug in the plugin.

{#each things as thing, idx (`thing-${idx}`)}

is giving me this message:

9:63  warning  'idx' is not defined            missing-declaration

using svelte@3.5.3, eslint-plugin-svelte3@2.6.0, and eslint@6.0.1

Conduitry commented 5 years ago

missing-declaration is a warning from the compiler, so this seems like a bug in Svelte and not in this plugin. If you stick the same code in the REPL you'll see that warning there as well.

Does this code work properly apart from the warning? Does the keyed value actually have access to the index variable, or is there a bigger problem here?

tivac commented 5 years ago

Whoops, should've dug into that further. The keying is a little nonsensical (keying by only array index is pointless) but does seem to function fine yes.

Conduitry commented 5 years ago

Fixed in Svelte v3.6.11.