Please describe what the rule should do:
Disallow using array item index as key in v-for iteration.
This rule should do the same as no-array-index-key in eslint-plugin-react
What category should the rule belong to?
Code examples that this rule should warn about
Incorrect code:
<template>
<ul>
<!-- List is an array, item index cannot be a stable key -->
<li v-for="(item, index) in list" :key="index"></li>
</ul>
</template>
Correct code:
<template>
<ul>
<!-- List is an array, each item has unique stable key named id -->
<li v-for="item in list" :key="item.id"></li>
</ul>
</template>
Correct code:
<template>
<ul>
<!-- List is an object, each key is unique stable key -->
<li v-for="(value, key) in object" :key="key"></li>
</ul>
Additional context
This issue is a duplicate of #1746 from 2021. I hope now we can determine a difference between array and object in v-for at a linter level using TypeScript.
Please describe what the rule should do:
Disallow using array item index as key in
v-foriteration.This rule should do the same as no-array-index-key in eslint-plugin-react
What category should the rule belong to?
Code examples that this rule should warn about
Incorrect code:
Correct code:
Correct code:
Additional context
This issue is a duplicate of #1746 from 2021. I hope now we can determine a difference between array and object in
v-forat a linter level using TypeScript.