You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
no-raw-text: TypeError on template literals with no interpolations aborts the lint run #341
The TemplateLiteral visitor runs for every template literal in a JSX expression container, but node.expressions is [] when there are no interpolations, so node.expressions[0] is undefined.
There is a second, milder case: when expressions[0] is not an Identifier, .name is undefined
and the message degrades. <View>{hi ${a.b}}</View> currently reports:
Raw text (TemplateLiteral: undefined) cannot be used outside of a <Text> tag
Suggested fix
Both cases come from assuming expressions[0] exists and is an Identifier. Something like:
That reports the literal text when there are no interpolations, and falls back to the expression's
source text otherwise, so the message stays useful in both cases.
Happy to open a PR if that's welcome — it's a small change and I have tests for both cases.
Activity