From 3915bb43169ae501d81571c5e1efa12cf0e24dbb Mon Sep 17 00:00:00 2001 From: dan Date: Thu, 4 Apr 2024 21:34:55 +0100 Subject: 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 --- eslint/__tests__/avoid-unwrapped-text.test.js | 65 +++++++++++++++++++++++++++ 1 file changed, 65 insertions(+) (limited to 'eslint/__tests__/avoid-unwrapped-text.test.js') 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', () => { `, }, + + { + code: ` +function Stuff() { + return foo +} + `, + }, + + { + code: ` +function Stuff({ foo }) { + return {foo} +} + `, + }, + + { + code: ` +function MyText() { + return foo +} + `, + }, + + { + code: ` +function MyText({ foo }) { + if (foo) { + return foo + } + return foo +} + `, + }, ], invalid: [ @@ -390,6 +425,36 @@ describe('avoid-unwrapped-text', () => { `, errors: 1, }, + + { + code: ` +function MyText() { + return +} + `, + errors: 1, + }, + + { + code: ` +function MyText({ foo }) { + return {foo} +} + `, + errors: 1, + }, + + { + code: ` +function MyText({ foo }) { + if (foo) { + return {foo} + } + return foo +} + `, + errors: 1, + }, ], } -- cgit 1.4.1