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: [ {