@@ -46,6 +46,30 @@ function mergeUsedPropTypes(propsList, newPropsList) {
46
46
return propsList . concat ( propsToAdd ) ;
47
47
}
48
48
49
+ function isReturnsConditionalJSX ( node , property , strict ) {
50
+ const returnsConditionalJSXConsequent = node [ property ] &&
51
+ node [ property ] . type === 'ConditionalExpression' &&
52
+ jsxUtil . isJSX ( node [ property ] . consequent ) ;
53
+ const returnsConditionalJSXAlternate = node [ property ] &&
54
+ node [ property ] . type === 'ConditionalExpression' &&
55
+ jsxUtil . isJSX ( node [ property ] . alternate ) ;
56
+ return strict ?
57
+ ( returnsConditionalJSXConsequent && returnsConditionalJSXAlternate ) :
58
+ ( returnsConditionalJSXConsequent || returnsConditionalJSXAlternate ) ;
59
+ }
60
+
61
+ function isReturnsLogicalJSX ( node , property , strict ) {
62
+ const returnsLogicalJSXLeft = node [ property ] &&
63
+ node [ property ] . type === 'LogicalExpression' &&
64
+ jsxUtil . isJSX ( node [ property ] . left ) ;
65
+ const returnsLogicalJSXRight = node [ property ] &&
66
+ node [ property ] . type === 'LogicalExpression' &&
67
+ jsxUtil . isJSX ( node [ property ] . right ) ;
68
+ return strict ?
69
+ ( returnsLogicalJSXLeft && returnsLogicalJSXRight ) :
70
+ ( returnsLogicalJSXLeft || returnsLogicalJSXRight ) ;
71
+ }
72
+
49
73
const Lists = new WeakMap ( ) ;
50
74
51
75
/**
@@ -373,22 +397,15 @@ function componentRule(rule, context) {
373
397
return false ;
374
398
}
375
399
376
- const returnsConditionalJSXConsequent = node [ property ] &&
377
- node [ property ] . type === 'ConditionalExpression' &&
378
- jsxUtil . isJSX ( node [ property ] . consequent ) ;
379
- const returnsConditionalJSXAlternate = node [ property ] &&
380
- node [ property ] . type === 'ConditionalExpression' &&
381
- jsxUtil . isJSX ( node [ property ] . alternate ) ;
382
- const returnsConditionalJSX = strict ?
383
- ( returnsConditionalJSXConsequent && returnsConditionalJSXAlternate ) :
384
- ( returnsConditionalJSXConsequent || returnsConditionalJSXAlternate ) ;
400
+ const returnsConditionalJSX = isReturnsConditionalJSX ( node , property , strict ) ;
401
+ const returnsLogicalJSX = isReturnsLogicalJSX ( node , property , strict ) ;
385
402
386
- const returnsJSX = node [ property ] &&
387
- jsxUtil . isJSX ( node [ property ] ) ;
403
+ const returnsJSX = node [ property ] && jsxUtil . isJSX ( node [ property ] ) ;
388
404
const returnsPragmaCreateElement = this . isCreateElement ( node [ property ] ) ;
389
405
390
- return Boolean (
406
+ return ! ! (
391
407
returnsConditionalJSX ||
408
+ returnsLogicalJSX ||
392
409
returnsJSX ||
393
410
returnsPragmaCreateElement
394
411
) ;
0 commit comments