Skip to content

Commit ced9494

Browse files
committed
moved logic to lineShouldEndWithSemicolon
1 parent c2bc0fc commit ced9494

File tree

2 files changed

+12
-9
lines changed

2 files changed

+12
-9
lines changed

src/printer.mjs

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -115,15 +115,7 @@ function genericPrint(path, options, print) {
115115
}
116116

117117
if (lineShouldEndWithSemicolon(path)) {
118-
const isPipeChainStatement =
119-
node.kind === "expressionstatement" &&
120-
((node.expression.kind === "bin" && node.expression.type === "|>") ||
121-
(node.expression.kind === "assign" &&
122-
node.expression.right.kind === "bin" &&
123-
node.expression.right.type === "|>"));
124-
if (!isPipeChainStatement) {
125-
parts.push(";");
126-
}
118+
parts.push(";");
127119
}
128120

129121
if (fileShouldEndWithHardline(path)) {

src/util.mjs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -360,6 +360,17 @@ function lineShouldEndWithSemicolon(path) {
360360
return true;
361361
}
362362
}
363+
if (node.kind === "expressionstatement") {
364+
const expr = node.expression;
365+
const isPipeChain =
366+
(expr.kind === "bin" && expr.type === "|>") ||
367+
(expr.kind === "assign" &&
368+
expr.right.kind === "bin" &&
369+
expr.right.type === "|>");
370+
if (isPipeChain) {
371+
return false;
372+
}
373+
}
363374
return [
364375
"expressionstatement",
365376
"do",

0 commit comments

Comments
 (0)