Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
yepMad opened this issue Mar 26, 2023 · 1 comment
Open

Comments

@yepMad
Copy link

yepMad commented Mar 26, 2023

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)```
@ejfrancis
Copy link

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();

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants