eslint-plugin-react-native
eslint-plugin-react-native copied to clipboard
no-raw-text should use types
The no-raw-text rule could be made much more robust by using TypeScript types.
Currently, the rule detects simple usage like <View>foo</View>
and <View>{'foo'}</View>
but using any variables prevents detection <View>{textVar}</View>
. Also numbers are not detected, the following does not product a warning <View>{0}</View>
.
A very common type of bug I see is the following:
{ myVar && <MyComponent var={myVar} /> }
This works find as long as myVar
has content or is undefined/null/false, but if it is an empty string or zero, it causes an Invariant Violation crash. Using types would allow catching this type of bug as well. (The correct way is to use !!myVar
in the condition if the variable is non-boolean.)
is someone working on it, or has any suggestions on how to approach it?
Up