Skip to content

Commit 2ae8d5e

Browse files
committed
Find usages of literals as a part of BinaryExpressions in jsx-no-literals
1 parent 4cf6752 commit 2ae8d5e

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

lib/rules/jsx-no-literals.js

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,11 +43,15 @@ module.exports = {
4343
}
4444

4545
function getValidation(node) {
46+
let current = node;
47+
while (current.parent.type === 'BinaryExpression') {
48+
current = current.parent;
49+
}
4650
const standard = !/^[\s]+$/.test(node.value) &&
4751
typeof node.value === 'string' &&
48-
node.parent &&
49-
node.parent.type.indexOf('JSX') !== -1 &&
50-
node.parent.type !== 'JSXAttribute';
52+
current.parent &&
53+
current.parent.type.indexOf('JSX') !== -1 &&
54+
current.parent.type !== 'JSXAttribute';
5155
if (isNoStrings) {
5256
return standard;
5357
}

0 commit comments

Comments
 (0)