5165d32 Nov 9, 2015
31 lines (19 sloc) 738 Bytes

Detect missing key prop (jsx-key)

Warn if an element that likely requires a key prop--namely, one present in an array literal or an arrow function expression.

Rule Details

The following patterns are considered warnings:

[<Hello />, <Hello />, <Hello />]; => <Hello>x</Hello>);

The following patterns are not considered warnings:

[<Hello key="first" />, <Hello key="second" />, <Hello key="third" />];, i) => <Hello key={i}>x</Hello>);

When not to use

If you are not using JSX then you can disable this rule.

Also, if you have some prevalent situation where you use arrow functions to return JSX that will not be held in an iterable, you may want to disable this rule.