From cb5e1db4a511ddab6c4cc10aa0f484346b16ac28 Mon Sep 17 00:00:00 2001 From: Suchipi Date: Fri, 22 Jun 2018 10:32:38 -0600 Subject: [PATCH] Revert "Ternary Operators in JSX Expression Containers (#4731)" (#4736) This reverts commit 12046cd01b05b5053de0ad5234564bd9af260000. --- src/language-js/printer-estree.js | 3 +-- tests/jsx/__snapshots__/jsfmt.spec.js.snap | 20 -------------------- tests/jsx/conditional-expression.js | 10 ---------- 3 files changed, 1 insertion(+), 32 deletions(-) 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." - )} -