File tree Expand file tree Collapse file tree 1 file changed +11
-6
lines changed Expand file tree Collapse file tree 1 file changed +11
-6
lines changed Original file line number Diff line number Diff line change @@ -42,20 +42,24 @@ module.exports = {
42
42
} ) ;
43
43
}
44
44
45
- function getValidation ( node ) {
45
+ function getParentIgnoringBinaryExpressions ( node ) {
46
46
let current = node ;
47
47
while ( current . parent . type === 'BinaryExpression' ) {
48
48
current = current . parent ;
49
49
}
50
+ return current . parent ;
51
+ }
52
+
53
+ function getValidation ( node ) {
54
+ const parent = getParentIgnoringBinaryExpressions ( node ) ;
50
55
const standard = ! / ^ [ \s ] + $ / . test ( node . value ) &&
51
56
typeof node . value === 'string' &&
52
- current . parent &&
53
- current . parent . type . indexOf ( 'JSX' ) !== - 1 &&
54
- current . parent . type !== 'JSXAttribute' ;
57
+ parent . type . indexOf ( 'JSX' ) !== - 1 &&
58
+ parent . type !== 'JSXAttribute' ;
55
59
if ( isNoStrings ) {
56
60
return standard ;
57
61
}
58
- return standard && node . parent . type !== 'JSXExpressionContainer' ;
62
+ return standard && parent . type !== 'JSXExpressionContainer' ;
59
63
}
60
64
61
65
// --------------------------------------------------------------------------
@@ -71,7 +75,8 @@ module.exports = {
71
75
} ,
72
76
73
77
TemplateLiteral : function ( node ) {
74
- if ( isNoStrings && node . parent . type === 'JSXExpressionContainer' ) {
78
+ const parent = getParentIgnoringBinaryExpressions ( node ) ;
79
+ if ( isNoStrings && parent . type === 'JSXExpressionContainer' ) {
75
80
reportLiteralNode ( node ) ;
76
81
}
77
82
}
You can’t perform that action at this time.
0 commit comments