@@ -42,6 +42,8 @@ ruleTester.run('jsx-key', rule, {
42
42
{ code : '[<App key={0} />, <App key={1} />];' } ,
43
43
{ code : '[1, 2, 3].map(function(x) { return <App key={x} /> });' } ,
44
44
{ code : '[1, 2, 3].map(x => <App key={x} />);' } ,
45
+ { code : '[1, 2 ,3].map(x => x && <App x={x} key={x} />);' } ,
46
+ { code : '[1, 2 ,3].map(x => x ? <App x={x} key="1" /> : <OtherApp x={x} key="2" />);' } ,
45
47
{ code : '[1, 2, 3].map(x => { return <App key={x} /> });' } ,
46
48
{ code : 'Array.from([1, 2, 3], function(x) { return <App key={x} /> });' } ,
47
49
{ code : 'Array.from([1, 2, 3], (x => <App key={x} />));' } ,
@@ -188,10 +190,10 @@ ruleTester.run('jsx-key', rule, {
188
190
code : `
189
191
import Act from 'react';
190
192
import { Children as ReactChildren } from 'react';
191
-
193
+
192
194
const { Children } = Act;
193
195
const { toArray } = Children;
194
-
196
+
195
197
Act.Children.toArray([1, 2 ,3].map(x => <App />));
196
198
Act.Children.toArray(Array.from([1, 2 ,3], x => <App />));
197
199
Children.toArray([1, 2 ,3].map(x => <App />));
@@ -225,6 +227,18 @@ ruleTester.run('jsx-key', rule, {
225
227
code : '[1, 2 ,3].map(x => <App />);' ,
226
228
errors : [ { messageId : 'missingIterKey' } ] ,
227
229
} ,
230
+ {
231
+ code : '[1, 2 ,3].map(x => x && <App x={x} />);' ,
232
+ errors : [ { messageId : 'missingIterKey' } ] ,
233
+ } ,
234
+ {
235
+ code : '[1, 2 ,3].map(x => x ? <App x={x} key="1" /> : <OtherApp x={x} />);' ,
236
+ errors : [ { messageId : 'missingIterKey' } ] ,
237
+ } ,
238
+ {
239
+ code : '[1, 2 ,3].map(x => x ? <App x={x} /> : <OtherApp x={x} key="2" />);' ,
240
+ errors : [ { messageId : 'missingIterKey' } ] ,
241
+ } ,
228
242
{
229
243
code : '[1, 2 ,3].map(x => { return <App /> });' ,
230
244
errors : [ { messageId : 'missingIterKey' } ] ,
0 commit comments