Skip to content

Commit

Permalink
[Fix] jsx-curly-brace-presence: accept multiline template string
Browse files Browse the repository at this point in the history
Fixes #1592
  • Loading branch information
golopot authored and ljharb committed Mar 17, 2019
1 parent 2c091dd commit 21b7edd
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 0 deletions.
1 change: 1 addition & 0 deletions lib/rules/jsx-curly-brace-presence.js 100644 → 100755
Expand Up @@ -182,6 +182,7 @@ module.exports = {
} else if (
expressionType === 'TemplateLiteral' &&
expression.expressions.length === 0 &&
expression.quasis[0].value.raw.indexOf('\n') === -1 &&
!needToEscapeCharacterForJSX(expression.quasis[0].value.raw) && (
jsxUtil.isJSX(JSXExpressionNode.parent) ||
!containsQuoteCharacters(expression.quasis[0].value.cooked)
Expand Down
38 changes: 38 additions & 0 deletions tests/lib/rules/jsx-curly-brace-presence.js 100644 → 100755
Expand Up @@ -241,6 +241,44 @@ ruleTester.run('jsx-curly-brace-presence', rule, {
{
code: ['<a a={"start\\', '\\', 'end"}/>'].join('/n'),
options: ['never']
},
{
code: `
<App prop={\`
a
b
\`} />
`,
options: ['never']
},
{
code: `
<App prop={\`
a
b
\`} />
`,
options: ['always']
},
{
code: `
<App>
{\`
a
b
\`}
</App>
`,
options: ['never']
},
{
code: `
<App>{\`
a
b
\`}</App>
`,
options: ['always']
}
],

Expand Down

0 comments on commit 21b7edd

Please sign in to comment.