A list element's key is its index in the array
What it finds
items.map((item, i) => <Row key={i} />): a key made from the position in the list stays with the position, not with the item. When items are inserted, removed or reordered, React gives the state of one item to another. An id of the item keeps them apart.
Reported are key attributes whose value is the second parameter of the callback of a map call, alone or in a template. Lists that never change order can use the index safely, which is why the rule is strict.
From the rule's source, index_as_key.rs.
Turn it on, off or suppress it
The rule runs from the strict tier up. To turn it on in a lower tier, give it a level in tx0.toml:
[rules]
"tx0/ts:index-as-key" = "warning"To keep one finding, suppress it with a reason. tx0 suppress ID --reason "..." writes the comment on the line before the code:
// tx0: ignore[tx0/ts:index-as-key] reason="..."tx0 explain tx0/ts:index-as-key shows the same in the terminal. Found a false positive? Report it.