eslint-plugin-react-native icon indicating copy to clipboard operation
eslint-plugin-react-native copied to clipboard

[react-native/no-raw-tex] crash when have a template literals string

Open yepMad opened this issue 2 years ago • 2 comments

Code:

<View>
  <Text>{`Text text text text`}</Text>
</View>

Error:

Rule: "react-native/no-raw-text"
    at report (C:\Users\eudes\Documents\Git\lumine\node_modules\eslint-plugin-react-native\lib\rules\no-raw-text.js:34:49)
    at TemplateLiteral (C:\Users\eudes\Documents\Git\lumine\node_modules\eslint-plugin-react-native\lib\rules\no-raw-text.js:85:9)
    at ruleErrorHandler (C:\Users\eudes\Documents\Git\lumine\node_modules\eslint\lib\linter\linter.js:1118:28)
    at C:\Users\eudes\Documents\Git\lumine\node_modules\eslint\lib\linter\safe-emitter.js:45:58
    at Array.forEach (<anonymous>)
    at Object.emit (C:\Users\eudes\Documents\Git\lumine\node_modules\eslint\lib\linter\safe-emitter.js:45:38)
    at NodeEventGenerator.applySelector (C:\Users\eudes\Documents\Git\lumine\node_modules\eslint\lib\linter\node-event-generator.js:297:26)
    at NodeEventGenerator.applySelectors (C:\Users\eudes\Documents\Git\lumine\node_modules\eslint\lib\linter\node-event-generator.js:326:22)
    at NodeEventGenerator.enterNode (C:\Users\eudes\Documents\Git\lumine\node_modules\eslint\lib\linter\node-event-generator.js:340:14)
    at CodePathAnalyzer.enterNode (C:\Users\eudes\Documents\Git\lumine\node_modules\eslint\lib\linter\code-path-analysis\code-path-analyzer.js:795:23)```

yepMad avatar Mar 26 '23 07:03 yepMad

I see the same error

TypeError: Cannot read properties of undefined (reading 'name')

The error is on this line because node.expressions is an empty array []

 const report = (node) => {
    const errorValue = node.type === 'TemplateLiteral'
      ? `TemplateLiteral: ${node.expressions[0].name}`
      : node.value.trim();

ejfrancis avatar Mar 31 '23 17:03 ejfrancis