From fd6fff8427a8d99fb4af1103f407df798fb35d9a Mon Sep 17 00:00:00 2001 From: akulsr0 Date: Thu, 8 Aug 2024 19:34:10 +0530 Subject: [PATCH] fix: doesn't trigger on strings containing a quote character --- lib/rules/jsx-curly-brace-presence.js | 2 +- tests/lib/rules/jsx-curly-brace-presence.js | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/lib/rules/jsx-curly-brace-presence.js b/lib/rules/jsx-curly-brace-presence.js index 083a60a0e3..786f8c888a 100755 --- a/lib/rules/jsx-curly-brace-presence.js +++ b/lib/rules/jsx-curly-brace-presence.js @@ -268,7 +268,7 @@ module.exports = { && !containsMultilineComment(expression.value) && !needToEscapeCharacterForJSX(expression.raw, JSXExpressionNode) && ( jsxUtil.isJSX(JSXExpressionNode.parent) - || !containsQuoteCharacters(expression.value) + || (!containsQuoteCharacters(expression.value) || typeof expression.value === 'string') ) ) { reportUnnecessaryCurly(JSXExpressionNode); diff --git a/tests/lib/rules/jsx-curly-brace-presence.js b/tests/lib/rules/jsx-curly-brace-presence.js index 4c157deb0c..2d66c19de5 100755 --- a/tests/lib/rules/jsx-curly-brace-presence.js +++ b/tests/lib/rules/jsx-curly-brace-presence.js @@ -934,6 +934,13 @@ ruleTester.run('jsx-curly-brace-presence', rule, { errors: [{ messageId: 'unnecessaryCurly' }], options: [{ props: 'never', children: 'never', propElementValues: 'never' }], features: ['no-ts'], + }, + { + code: ``, + output: ``, + errors: [{ messageId: 'unnecessaryCurly' }], + options: [{ props: 'never', children: 'never', propElementValues: 'never' }], + features: ['no-ts'], } )), });