Skip to content

Commit 21b7edd

Browse files
golopotljharb
authored andcommitted
[Fix] jsx-curly-brace-presence: accept multiline template string
Fixes jsx-eslint#1592
1 parent 2c091dd commit 21b7edd

File tree

2 files changed

+39
-0
lines changed

2 files changed

+39
-0
lines changed

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

100644100755
+1
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,7 @@ module.exports = {
182182
} else if (
183183
expressionType === 'TemplateLiteral' &&
184184
expression.expressions.length === 0 &&
185+
expression.quasis[0].value.raw.indexOf('\n') === -1 &&
185186
!needToEscapeCharacterForJSX(expression.quasis[0].value.raw) && (
186187
jsxUtil.isJSX(JSXExpressionNode.parent) ||
187188
!containsQuoteCharacters(expression.quasis[0].value.cooked)

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

100644100755
+38
Original file line numberDiff line numberDiff line change
@@ -241,6 +241,44 @@ ruleTester.run('jsx-curly-brace-presence', rule, {
241241
{
242242
code: ['<a a={"start\\', '\\', 'end"}/>'].join('/n'),
243243
options: ['never']
244+
},
245+
{
246+
code: `
247+
<App prop={\`
248+
a
249+
b
250+
\`} />
251+
`,
252+
options: ['never']
253+
},
254+
{
255+
code: `
256+
<App prop={\`
257+
a
258+
b
259+
\`} />
260+
`,
261+
options: ['always']
262+
},
263+
{
264+
code: `
265+
<App>
266+
{\`
267+
a
268+
b
269+
\`}
270+
</App>
271+
`,
272+
options: ['never']
273+
},
274+
{
275+
code: `
276+
<App>{\`
277+
a
278+
b
279+
\`}</App>
280+
`,
281+
options: ['always']
244282
}
245283
],
246284

0 commit comments

Comments
 (0)