Content-Length: 325988 | pFad | http://github.com/jsx-eslint/eslint-plugin-react/commit/10eb2350a42e4645f33a594f63e74fc3aceef939

D7 [Fix] `jsx-curly-brace-presence`: do not trigger on strings containin… · jsx-eslint/eslint-plugin-react@10eb235 · GitHub
Skip to content

Commit 10eb235

Browse files
akulsr0ljharb
authored andcommitted
[Fix] jsx-curly-brace-presence: do not trigger on strings containing a quote character
1 parent 0170dbe commit 10eb235

File tree

3 files changed

+12
-1
lines changed

3 files changed

+12
-1
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,11 @@ This change log adheres to standards from [Keep a CHANGELOG](https://keepachange
55

66
## Unreleased
77

8+
### Fixed
9+
* [`jsx-curly-brace-presence`]: do not trigger on strings containing a quote character ([#3798][] @akulsr0)
10+
11+
[#3798]: https://github.com/jsx-eslint/eslint-plugin-react/pull/3798
12+
813
## [7.35.0] - 2024.07.19
914

1015
### Added

lib/rules/jsx-curly-brace-presence.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,7 @@ module.exports = {
269269
&& !containsMultilineComment(expression.value)
270270
&& !needToEscapeCharacterForJSX(expression.raw, JSXExpressionNode) && (
271271
jsxUtil.isJSX(JSXExpressionNode.parent)
272-
|| !containsQuoteCharacters(expression.value)
272+
|| (!containsQuoteCharacters(expression.value) || typeof expression.value === 'string')
273273
)
274274
) {
275275
reportUnnecessaryCurly(JSXExpressionNode);

tests/lib/rules/jsx-curly-brace-presence.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -934,6 +934,12 @@ ruleTester.run('jsx-curly-brace-presence', rule, {
934934
errors: [{ messageId: 'unnecessaryCurly' }],
935935
options: [{ props: 'never', children: 'never', propElementValues: 'never' }],
936936
features: ['no-ts'],
937+
},
938+
{
939+
code: `<Foo bar={"'"} />`,
940+
output: `<Foo bar="'" />`,
941+
errors: [{ messageId: 'unnecessaryCurly' }],
942+
options: [{ props: 'never', children: 'never', propElementValues: 'never' }],
937943
}
938944
)),
939945
});

0 commit comments

Comments
 (0)








ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: http://github.com/jsx-eslint/eslint-plugin-react/commit/10eb2350a42e4645f33a594f63e74fc3aceef939

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy