Remove isLineNext (#10304)
* Replace `isLineNext` with `isLineOrHardlineOrSoftline` * Remove `isLineNext` * Use `isEmptyStringOrAnyLine` * Update condition
This commit is contained in:
1 parent
db2eb50e84
commit
bc30016500
2 files changed
+8
-22
No files matched your search
@@ -104,19 +104,6 @@ function findInDoc(doc, fn, defaultValue) {
|
||||
return result;
|
||||
}
|
||||
|
||||
function isLineNextFn(doc) {
|
||||
if (typeof doc === "string") {
|
||||
return false;
|
||||
}
|
||||
if (doc.type === "line") {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
function isLineNext(doc) {
|
||||
return findInDoc(doc, isLineNextFn, false);
|
||||
}
|
||||
|
||||
function willBreakFn(doc) {
|
||||
if (doc.type === "group" && doc.break) {
|
||||
return true;
|
||||
@@ -379,7 +366,6 @@ module.exports = {
|
||||
isConcat,
|
||||
getDocParts,
|
||||
willBreak,
|
||||
isLineNext,
|
||||
traverseDoc,
|
||||
findInDoc,
|
||||
mapDoc,
|
||||
|
||||
@@ -14,7 +14,7 @@ const {
|
||||
lineSuffixBoundary,
|
||||
join,
|
||||
},
|
||||
utils: { willBreak, isLineNext },
|
||||
utils: { willBreak },
|
||||
} = require("../../document");
|
||||
|
||||
const { getLast, getPreferredQuote } = require("../../common/util");
|
||||
@@ -32,6 +32,9 @@ const {
|
||||
const pathNeedsParens = require("../needs-parens");
|
||||
const { willPrintOwnComments } = require("../comments");
|
||||
|
||||
const isEmptyStringOrAnyLine = (doc) =>
|
||||
doc === "" || doc === line || doc === hardline || doc === softline;
|
||||
|
||||
/**
|
||||
* @typedef {import("../../common/ast-path")} AstPath
|
||||
* @typedef {import("../types/estree").Node} Node
|
||||
@@ -175,18 +178,15 @@ function printJsxElementInternal(path, options, print) {
|
||||
}
|
||||
|
||||
// Trim trailing lines (or empty strings)
|
||||
while (
|
||||
children.length > 0 &&
|
||||
(!getLast(children) || isLineNext(getLast(children)))
|
||||
) {
|
||||
while (children.length > 0 && isEmptyStringOrAnyLine(getLast(children))) {
|
||||
children.pop();
|
||||
}
|
||||
|
||||
// Trim leading lines (or empty strings)
|
||||
while (
|
||||
children.length > 0 &&
|
||||
(!children[0] || isLineNext(children[0])) &&
|
||||
(!children[1] || isLineNext(children[1]))
|
||||
children.length > 1 &&
|
||||
isEmptyStringOrAnyLine(children[0]) &&
|
||||
isEmptyStringOrAnyLine(children[1])
|
||||
) {
|
||||
children.shift();
|
||||
children.shift();
|
||||
|
||||
Reference in new issue
Block a user