diff options
author | dan <dan.abramov@gmail.com> | 2024-04-04 21:34:55 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-04-04 21:34:55 +0100 |
commit | 3915bb43169ae501d81571c5e1efa12cf0e24dbb (patch) | |
tree | be2f7bed7c842be71922f2793b4b4a20cd6fbc24 /eslint/__tests__/avoid-unwrapped-text.test.js | |
parent | c190fd58ec82b36ea8124902cad34acc4a5b5ac0 (diff) | |
download | voidsky-3915bb43169ae501d81571c5e1efa12cf0e24dbb.tar.zst |
Enforce Text suffix for Text-rendering components (#3407)
* Rm unused * Add Text suffix to Title/Description * Add Text suffix to text components * Add Text suffix to props * Validate Text components returns
Diffstat (limited to 'eslint/__tests__/avoid-unwrapped-text.test.js')
-rw-r--r-- | eslint/__tests__/avoid-unwrapped-text.test.js | 65 |
1 files changed, 65 insertions, 0 deletions
diff --git a/eslint/__tests__/avoid-unwrapped-text.test.js b/eslint/__tests__/avoid-unwrapped-text.test.js index 0fbc01123..7c667b4a8 100644 --- a/eslint/__tests__/avoid-unwrapped-text.test.js +++ b/eslint/__tests__/avoid-unwrapped-text.test.js @@ -246,6 +246,41 @@ describe('avoid-unwrapped-text', () => { </Foo> `, }, + + { + code: ` +function Stuff() { + return <Text>foo</Text> +} + `, + }, + + { + code: ` +function Stuff({ foo }) { + return <View>{foo}</View> +} + `, + }, + + { + code: ` +function MyText() { + return <Text>foo</Text> +} + `, + }, + + { + code: ` +function MyText({ foo }) { + if (foo) { + return <Text>foo</Text> + } + return <Text>foo</Text> +} + `, + }, ], invalid: [ @@ -390,6 +425,36 @@ describe('avoid-unwrapped-text', () => { `, errors: 1, }, + + { + code: ` +function MyText() { + return <Foo /> +} + `, + errors: 1, + }, + + { + code: ` +function MyText({ foo }) { + return <Foo>{foo}</Foo> +} + `, + errors: 1, + }, + + { + code: ` +function MyText({ foo }) { + if (foo) { + return <Foo>{foo}</Foo> + } + return <Text>foo</Text> +} + `, + errors: 1, + }, ], } |