@@ -42,6 +42,8 @@ ruleTester.run('jsx-key', rule, {
4242 { code : '[<App key={0} />, <App key={1} />];' } ,
4343 { code : '[1, 2, 3].map(function(x) { return <App key={x} /> });' } ,
4444 { 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" />);' } ,
4547 { code : '[1, 2, 3].map(x => { return <App key={x} /> });' } ,
4648 { code : 'Array.from([1, 2, 3], function(x) { return <App key={x} /> });' } ,
4749 { code : 'Array.from([1, 2, 3], (x => <App key={x} />));' } ,
@@ -188,10 +190,10 @@ ruleTester.run('jsx-key', rule, {
188190 code : `
189191 import Act from 'react';
190192 import { Children as ReactChildren } from 'react';
191-
193+
192194 const { Children } = Act;
193195 const { toArray } = Children;
194-
196+
195197 Act.Children.toArray([1, 2 ,3].map(x => <App />));
196198 Act.Children.toArray(Array.from([1, 2 ,3], x => <App />));
197199 Children.toArray([1, 2 ,3].map(x => <App />));
@@ -225,6 +227,18 @@ ruleTester.run('jsx-key', rule, {
225227 code : '[1, 2 ,3].map(x => <App />);' ,
226228 errors : [ { messageId : 'missingIterKey' } ] ,
227229 } ,
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+ } ,
228242 {
229243 code : '[1, 2 ,3].map(x => { return <App /> });' ,
230244 errors : [ { messageId : 'missingIterKey' } ] ,
0 commit comments