Skip to content

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

Open
@DetachHead

Description

@DetachHead

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.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=

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions