sveltejs / eslint-plugin-svelte

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

`svelte/require-each-key` should not apply when the array is `readonly` #555

Open DetachHead opened 1 year ago

DetachHead commented 1 year ago

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

What version of ESLint are you using?

8.33.0

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

2.32.4

What did you do?

<script lang='ts'>
  const foo = [1,2,3] as const
</script>

{#each foo as value}
{/each}

What did you expect to happen?

no error, because the array cannot be changed so it's safe to iterate over it without a key

What actually happened?

[6:1]: Each block should have a key (svelte/require-each-key)

Link to GitHub Repo with Minimal Reproducible Example

https://sveltejs.github.io/eslint-plugin-svelte/playground/#eJwly0EOwiAQheGrTMZFNzTEuiOtFxEXhI7aSEAZaGIId5e22+/9r6ANM6HCkW1cPgmc8c+pS9xdtQewwXOCRwgwwe0sBnG5g+GDtR/lcWqp9uVExr72thWrcZlqU7lpRYExO2JUBXkll0hG+uYlUr/t/Zt+qIZa/4f9MVs=