From 5c70c33a2e67146d7df81997eced83754e47a292 Mon Sep 17 00:00:00 2001 From: Adriano Cola Date: Tue, 25 Aug 2020 16:46:39 -0300 Subject: [PATCH] Fixes no-raw-text rule for components with props --- lib/rules/no-raw-text.js | 5 ++++- tests/lib/rules/no-raw-text.js | 9 +++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/lib/rules/no-raw-text.js b/lib/rules/no-raw-text.js index b25593a..6434bf9 100644 --- a/lib/rules/no-raw-text.js +++ b/lib/rules/no-raw-text.js @@ -14,7 +14,10 @@ const elementName = (node, scope) => { JSXOpeningElement({ node: element }) { traverse(element, { JSXIdentifier({ node: identifier }) { - identifiers.push(identifier.name); + if (identifier.parent.type === 'JSXOpeningElement' + || identifier.parent.type === 'JSXMemberExpression') { + identifiers.push(identifier.name); + } }, }, scope); }, diff --git a/tests/lib/rules/no-raw-text.js b/tests/lib/rules/no-raw-text.js index eef9664..826ee9e 100644 --- a/tests/lib/rules/no-raw-text.js +++ b/tests/lib/rules/no-raw-text.js @@ -105,6 +105,15 @@ const tests = { `, options: [{ skip: ['Title.Text'] }], }, + { + code: ` + export default class MyComponent extends Component { + render() { + return (some text); + } + } + `, + }, ], invalid: [ {