no-v-for-template-key-on-child
Angular templatesHTMLVue / SvelteVue / Sveltecorrectnessno fixdefault: warnhtml/eslint-plugin-vue-recommended
What it does
Section titled “What it does”Reports a :key on a child of a <template v-for>.
Why it matters
Section titled “Why it matters”In Vue 3 the key belongs on the <template v-for>; a key on a child is not used, so the list is patched in place and state stays on the wrong element.
To fix, move the :key to the <template>.
Example
Section titled “Example”... <component :is="view" /> <template v-for="x in xs"><li :key="x" /></template>... <MyCard v-for="x in xs" />...Configuration
Section titled “Configuration”angular: lint: rules: no-v-for-template-key-on-child: warn # off, warn (default), errorhtml: lint: rules: no-v-for-template-key-on-child: warn # off, warn (default), errorsvelte: lint: rules: no-v-for-template-key-on-child: warn # off, warn (default), errorvue: lint: rules: no-v-for-template-key-on-child: warn # off, warn (default), errorEnabled by the presets: html/eslint-plugin-vue-recommended.
Suppress one line with sudsy-disable-next-line no-v-for-template-key-on-child 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-vue | no-v-for-template-key-on-child |
full |