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

no-raw-text nested text issue

Open BPetronel opened this issue 5 years ago • 6 comments

On "eslint-plugin-react-native": "3.9.1" there seems to be a false positive error/warning

<Text testID="OuterTestId">
	Message from
	<Text numberOfLines={1} ellipsizeMode="middle" style={styles.middleText}>
		{username}
	</Text>
</Text>

There seems to be a problem with Nested Text for this rule.

BPetronel avatar Sep 08 '20 12:09 BPetronel

The issue exists on v3.9.0 too. v3.8.1 is fine though. I'm testing with a custom text component like so: "react-native/no-raw-text": [2, { "skip": [ "Label" ] }],

rsml avatar Sep 17 '20 05:09 rsml

Any help on this issue is appreciated, I think its the same as this: https://github.com/Intellicode/eslint-plugin-react-native/issues/269

Intellicode avatar Oct 01 '20 20:10 Intellicode

Still present in "eslint-plugin-react-native": "^3.10.0"

DaniyarJakupov avatar Mar 18 '21 13:03 DaniyarJakupov

Still present in 3.11.0. As a workaround, you can configure the rule with { "skip": [ "Text.Text" ] }] (add "Text.Text.Text" for two levels of nesting etc).

ejain avatar Jun 09 '21 18:06 ejain

Noticed in 3.11.0 too, cheers @ejain this works for me

'react-native/no-raw-text': ['error', { skip: 'Text.Text' }]

leotm avatar Jun 19 '21 19:06 leotm

Yeah, I found this really confusing as nesting text like this is exactly what the React Native docs tell you to do. I made a YAML version of the workaround by ejain:

  react-native/no-raw-text:
    - error
    - skip:
        - 'Text.Text'

pipedreambomb avatar Jul 07 '21 12:07 pipedreambomb