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

no-raw-text should use types

Open plaa opened this issue 4 years ago • 2 comments

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.)

plaa avatar Jun 01 '20 05:06 plaa

is someone working on it, or has any suggestions on how to approach it?

DrRefactor avatar Dec 04 '20 15:12 DrRefactor

Up

ftzi avatar Sep 10 '21 03:09 ftzi