require-each-key
Angular templatesHTMLVue / SvelteVue / Sveltecorrectnessno fixdefault: warnhtml/eslint-plugin-svelte-recommended
What it does
Section titled “What it does”Reports an {#each} block with no key ({#each items as item}).
Why it matters
Section titled “Why it matters”Without a key the block updates the elements in place when the list changes, which keeps stale state in inputs and components and breaks transitions.
To fix, add a key, {#each items as item (item.id)}.
Example
Section titled “Example”{#each items as item} <p>{item}</p>{/each}{#each items as item (item.id)}...Configuration
Section titled “Configuration”angular: lint: rules: require-each-key: warn # off, warn (default), errorhtml: lint: rules: require-each-key: warn # off, warn (default), errorsvelte: lint: rules: require-each-key: warn # off, warn (default), errorvue: lint: rules: require-each-key: warn # off, warn (default), errorEnabled by the presets: html/eslint-plugin-svelte-recommended.
Suppress one line with sudsy-disable-next-line require-each-key in a comment of the file’s language.
Upstream equivalents
Section titled “Upstream equivalents”The same check in other tools; Sudsy reports what each upstream rule reports.
| Tool | Rule | Match |
|---|---|---|
| eslint-plugin-svelte | require-each-key |
full |