oursky / eslint-oursky

Apache License 2.0
2 stars 3 forks source link

Nested Text component recognized as raw text #42

Open wpyeon opened 1 year ago

wpyeon commented 1 year ago

https://github.com/oursky/eslint-oursky/blob/0267bdb60c56dd35b49193246c85667d8116ebb5/src/configs/reactnative.mjs#L7

I have trouble passing the lint test due to error when I nest a Text component inside another Text component:

<View>
  ...
  <Text style={styles.footnoteText}>
    {'*Only receipt scanning is available in the app.\n'}
    {'For other document types, please '}
    <Text style={styles.contactUsHyperlink} onPress={openURL}>
      {'contact us'}
    </Text>
    {'.'}
  </Text>
  ...
</View>

Error message:

error  Raw text (*Only receipt scanning is available in the app.) cannot be used outside of a <Text> tag  react-native/no-raw-text
louischan-oursky commented 1 year ago

It is a bug of the underlying eslint-plugin-react-native. But it has not been updated for a while. I guess you can disable this rule on that line with // eslint-disable-next-line react-native/no-raw-text. For details, see Disabling rules. When I have time, I would drop eslint-plugin-react-native and adopt @react-native-community/eslint-config instead.