From 2ae8d5edfbb6e1951d141e3cb88e88132375c3f0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B8rgen=20Aaberg?= Date: Sun, 17 Dec 2017 09:36:46 +0100 Subject: [PATCH] Find usages of literals as a part of BinaryExpressions in jsx-no-literals --- lib/rules/jsx-no-literals.js | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/lib/rules/jsx-no-literals.js b/lib/rules/jsx-no-literals.js index 797f5fc566..3a363f9fd1 100644 --- a/lib/rules/jsx-no-literals.js +++ b/lib/rules/jsx-no-literals.js @@ -43,11 +43,15 @@ module.exports = { } function getValidation(node) { + let current = node; + while (current.parent.type === 'BinaryExpression') { + current = current.parent; + } const standard = !/^[\s]+$/.test(node.value) && typeof node.value === 'string' && - node.parent && - node.parent.type.indexOf('JSX') !== -1 && - node.parent.type !== 'JSXAttribute'; + current.parent && + current.parent.type.indexOf('JSX') !== -1 && + current.parent.type !== 'JSXAttribute'; if (isNoStrings) { return standard; }