palantir / tslint-react

:orange_book: Lint rules related to React & JSX for TSLint.
Apache License 2.0
749 stars 76 forks source link

New Rule Suggestion: no-array-index-key #184

Closed Shobhit1 closed 5 years ago

Shobhit1 commented 6 years ago

Given that key help react identify which items have changed and React recommends that we do not add array indices as key, its probably a good idea that this rule is implemented as part of this library.

Explanation on Keys: https://reactjs.org/docs/lists-and-keys.html#keys

Negative impact of using array indices: https://medium.com/@robinpokorny/index-as-a-key-is-an-anti-pattern-e0349aece318

Similar rule is implemented in eslint-plugin-react: https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/no-array-index-key.md.

samueldepooter commented 5 years ago

This should really be a rule!

adidahiya commented 5 years ago

Sounds like a good idea, but we are closing requests for new rules due to the deprecation timeline: #210