diff --git a/lib/rules/jsx-curly-brace-presence.js b/lib/rules/jsx-curly-brace-presence.js
index 40030279b0..efdc8e6388 100755
--- a/lib/rules/jsx-curly-brace-presence.js
+++ b/lib/rules/jsx-curly-brace-presence.js
@@ -168,6 +168,10 @@ module.exports = {
});
}
+ function isWhiteSpaceLiteral(node) {
+ return node.type && node.type === 'Literal' && node.value && jsxUtil.isWhiteSpaces(node.value);
+ }
+
// Bail out if there is any character that needs to be escaped in JSX
// because escaping decreases readiblity and the original code may be more
// readible anyway or intentional for other specific reasons
@@ -178,6 +182,7 @@ module.exports = {
if (
(expressionType === 'Literal' || expressionType === 'JSXText') &&
typeof expression.value === 'string' &&
+ !isWhiteSpaceLiteral(expression) &&
!needToEscapeCharacterForJSX(expression.raw) && (
jsxUtil.isJSX(JSXExpressionNode.parent) ||
!containsQuoteCharacters(expression.value)
@@ -211,10 +216,6 @@ module.exports = {
);
}
- function isWhiteSpaceLiteral(node) {
- return node.type && node.type === 'Literal' && node.value && jsxUtil.isWhiteSpaces(node.value);
- }
-
function getAdjacentSiblings(node, children) {
for (let i = 1; i < children.length - 1; i++) {
const child = children[i];
diff --git a/tests/lib/rules/jsx-curly-brace-presence.js b/tests/lib/rules/jsx-curly-brace-presence.js
index 246197c3d9..0ef5dc41bb 100755
--- a/tests/lib/rules/jsx-curly-brace-presence.js
+++ b/tests/lib/rules/jsx-curly-brace-presence.js
@@ -52,9 +52,15 @@ ruleTester.run('jsx-curly-brace-presence', rule, {
{
code: '{\' \'}'
},
+ {
+ code: '{\' \'}\n'
+ },
{
code: '{\' \'}'
},
+ {
+ code: '{\' \'}\n'
+ },
{
code: '{\' \'}',
options: [{children: 'never'}]