Skip to content

Commit

Permalink
Merge pull request #268 from adrianocola/master
Browse files Browse the repository at this point in the history
Fixes no-raw-text rule for components with props
  • Loading branch information
Intellicode authored Aug 26, 2020
2 parents 886999a + 5c70c33 commit ad5b05a
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
5 changes: 4 additions & 1 deletion lib/rules/no-raw-text.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
},
Expand Down
9 changes: 9 additions & 0 deletions tests/lib/rules/no-raw-text.js
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,15 @@ const tests = {
`,
options: [{ skip: ['Title.Text'] }],
},
{
code: `
export default class MyComponent extends Component {
render() {
return (<View><Text style={{color: 'red'}}>some text</Text></View>);
}
}
`,
},
],
invalid: [
{
Expand Down

0 comments on commit ad5b05a

Please sign in to comment.