Skip to content

Commit

Permalink
unneeded check for new line on falseExpression
Browse files Browse the repository at this point in the history
  • Loading branch information
Janther committed Dec 2, 2023
1 parent 2111af0 commit 6fd4a21
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions src/nodes/Conditional.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,6 @@ const experimentalTernaries = (node, path, print) => {
const parent = path.getParentNode();
const isNested = parent.type === 'Conditional';
const isNestedAsTrueExpression = isNested && parent.trueExpression === node;
const hasNestedConditional =
node.trueExpression.type === 'Conditional' ||
node.falseExpression.type === 'Conditional';

// If the `conditionDoc` breaks into multiple lines, we add parentheses,
// unless it already is a `TupleExpression`.
Expand All @@ -29,10 +26,10 @@ const experimentalTernaries = (node, path, print) => {
path.call(print, 'trueExpression')
]);

// We force a new line if current `Conditional` is nested or nests a
// `Conditional`. Otherwise we add a normal line.
// We force a new line if current `Conditional` is a nested `Conditional`.
// Otherwise we add a normal line.
const falseExpressionDoc = [
isNested || hasNestedConditional ? hardline : line,
isNested ? hardline : line,
': ',
path.call(print, 'falseExpression')
];
Expand Down

0 comments on commit 6fd4a21

Please sign in to comment.