66
77'use strict' ;
88
9+ const arrayIncludes = require ( 'array-includes' ) ;
10+
911const docsUrl = require ( '../util/docsUrl' ) ;
1012const jsxUtil = require ( '../util/jsx' ) ;
1113
@@ -70,7 +72,7 @@ module.exports = {
7072 }
7173
7274 function containsBackslash ( rawStringValue ) {
73- return rawStringValue . includes ( '\\' ) ;
75+ return arrayIncludes ( rawStringValue , '\\' ) ;
7476 }
7577
7678 function containsHTMLEntity ( rawStringValue ) {
@@ -238,7 +240,12 @@ module.exports = {
238240
239241 return adjSiblings . some ( x => x . type && x . type === 'JSXExpressionContainer' ) ;
240242 }
243+ function hasAdjacentJsx ( node , children ) {
244+ const childrenExcludingWhitespaceLiteral = children . filter ( child => ! isWhiteSpaceLiteral ( child ) ) ;
245+ const adjSiblings = getAdjacentSiblings ( node , childrenExcludingWhitespaceLiteral ) ;
241246
247+ return adjSiblings . some ( x => x . type && arrayIncludes ( [ 'JSXExpressionContainer' , 'JSXElement' ] , x . type ) ) ;
248+ }
242249 function shouldCheckForUnnecessaryCurly ( parent , node , config ) {
243250 // Bail out if the parent is a JSXAttribute & its contents aren't
244251 // StringLiteral or TemplateLiteral since e.g
@@ -259,7 +266,9 @@ module.exports = {
259266 if ( jsxUtil . isJSX ( parent ) && hasAdjacentJsxExpressionContainers ( node , parent . children ) ) {
260267 return false ;
261268 }
262-
269+ if ( containsWhitespaceExpression ( node ) && hasAdjacentJsx ( node , parent . children ) ) {
270+ return false ;
271+ }
263272 if (
264273 parent . children &&
265274 parent . children . length === 1 &&
0 commit comments