Skip to content

Commit

Permalink
fix: doesn't trigger on strings containing a quote character
Browse files Browse the repository at this point in the history
  • Loading branch information
akulsr0 committed Aug 8, 2024
1 parent 1b4037f commit fd6fff8
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/rules/jsx-curly-brace-presence.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
7 changes: 7 additions & 0 deletions tests/lib/rules/jsx-curly-brace-presence.js
Original file line number Diff line number Diff line change
Expand Up @@ -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: `<Foo bar={"'"} />`,
output: `<Foo bar="'" />`,
errors: [{ messageId: 'unnecessaryCurly' }],
options: [{ props: 'never', children: 'never', propElementValues: 'never' }],
features: ['no-ts'],
}
)),
});

0 comments on commit fd6fff8

Please sign in to comment.