Skip to content

useVueVForKey

  • Rule available since: v2.3.11
  • Diagnostic Category: lint/correctness/useVueVForKey
  • This rule is recommended, meaning it is enabled by default.
  • This rule doesn’t have a fix.
  • The default severity of this rule is error.
  • This rule belongs to the following domains:
  • Sources:
biome.json
{
"linter": {
"rules": {
"correctness": {
"useVueVForKey": "error"
}
}
}
}

Enforce that elements using v-for also specify a unique key.

When rendering lists with v-for, Vue relies on a key to track elements efficiently. The key can be provided via longhand v-bind:key or shorthand :key. If you need to animate the entrance/exit of an item in a list, the key should be a unique identifier for each item in the list, and not the index of the item.

For more information, see the Vue documentation on list rendering.

<li v-for="item in items">{{ item }}</li>
<li v-for="item in items" :key="item.id">{{ item }}</li>
<li v-for="item in items" v-bind:key="item.id">{{ item }}</li>

Related rules: