diff --git a/src/language-js/printer-estree.js b/src/language-js/printer-estree.js index 84bdb4833..232d2a73f 100644 --- a/src/language-js/printer-estree.js +++ b/src/language-js/printer-estree.js @@ -243,8 +243,7 @@ function formatTernaryOperator(path, options, print, operatorOptions) { (operatorOpts.shouldCheckJsx && isJSXNode(n[operatorOpts.testNode])) || isJSXNode(n[operatorOpts.consequentNode]) || isJSXNode(n[operatorOpts.alternateNode]) || - conditionalExpressionChainContainsJSX(lastConditionalParent) || - firstNonConditionalParent.type === "JSXExpressionContainer" + conditionalExpressionChainContainsJSX(lastConditionalParent) ) { jsxMode = true; forceNoIndent = true; diff --git a/tests/jsx/__snapshots__/jsfmt.spec.js.snap b/tests/jsx/__snapshots__/jsfmt.spec.js.snap index ee1fe0969..bd3017560 100644 --- a/tests/jsx/__snapshots__/jsfmt.spec.js.snap +++ b/tests/jsx/__snapshots__/jsfmt.spec.js.snap @@ -240,16 +240,6 @@ cable ? ( ) ) : null} ; - -// This ConditionalExpression prints in JSX mode because the first -// non-conditional parent is a JSX expression container. -
- {data.length > 1 ? ( - "This is a really long non-jsx element inside of a ternary-operator that in turn is inside of a JSX expression container." - ) : ( - "This is string however, is not as long as the previous one." - )} -
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // There are two ways to print ConditionalExpressions: "normal mode" and // "JSX mode". This is normal mode (when breaking): @@ -395,16 +385,6 @@ cable ? ( ) : null} ; -// This ConditionalExpression prints in JSX mode because the first -// non-conditional parent is a JSX expression container. -
- {data.length > 1 ? ( - "This is a really long non-jsx element inside of a ternary-operator that in turn is inside of a JSX expression container." - ) : ( - "This is string however, is not as long as the previous one." - )} -
; - `; exports[`expression.js 1`] = ` diff --git a/tests/jsx/conditional-expression.js b/tests/jsx/conditional-expression.js index f38928daf..5266662a9 100644 --- a/tests/jsx/conditional-expression.js +++ b/tests/jsx/conditional-expression.js @@ -129,13 +129,3 @@ cable ? ( ) ) : null} ; - -// This ConditionalExpression prints in JSX mode because the first -// non-conditional parent is a JSX expression container. -
- {data.length > 1 ? ( - "This is a really long non-jsx element inside of a ternary-operator that in turn is inside of a JSX expression container." - ) : ( - "This is string however, is not as long as the previous one." - )} -