Skip to content

Commit bac0ec3

Browse files
committed
[Fix] jsx-curly-brace-presence: fix multiline comment case
Fixes #2716.
1 parent a77c0d1 commit bac0ec3

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,10 @@ module.exports = {
9292
return /['"]/.test(value);
9393
}
9494

95+
function containsMultilineComment(value) {
96+
return /\/\*/.test(value);
97+
}
98+
9599
function escapeDoubleQuotes(rawStringValue) {
96100
return rawStringValue.replace(/\\"/g, '"').replace(/"/g, '\\"');
97101
}
@@ -238,6 +242,7 @@ module.exports = {
238242
(JSXExpressionNode.parent.type === 'JSXAttribute' && !isWhiteSpaceLiteral(expression))
239243
|| !isLiteralWithTrailingWhiteSpaces(expression)
240244
)
245+
&& !containsMultilineComment(expression.value)
241246
&& !needToEscapeCharacterForJSX(expression.raw, JSXExpressionNode) && (
242247
jsxUtil.isJSX(JSXExpressionNode.parent)
243248
|| !containsQuoteCharacters(expression.value)

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

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -407,6 +407,16 @@ ruleTester.run('jsx-curly-brace-presence', rule, {
407407
};
408408
`,
409409
options: [{props: 'never', children: 'never'}]
410+
},
411+
{
412+
code: `
413+
import React from "react";
414+
415+
const Component = () => {
416+
return <span>{"/*"}</span>;
417+
};
418+
`,
419+
options: [{props: 'never', children: 'never'}]
410420
}
411421
],
412422

0 commit comments

Comments
 (0)