From 77dead370beaf39f761f59e88606f76535540f7a Mon Sep 17 00:00:00 2001 From: fisker Cheung Date: Sat, 10 Aug 2024 07:28:47 +0800 Subject: [PATCH] Simplify `printMemberChain` (#16535) --- src/language-js/print/member-chain.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/language-js/print/member-chain.js b/src/language-js/print/member-chain.js index 0caf225fc..ef3ba8910 100644 --- a/src/language-js/print/member-chain.js +++ b/src/language-js/print/member-chain.js @@ -94,11 +94,11 @@ function printMemberChain(path, options, print) { return isNextLineEmpty(node, options); } - function rec(path) { + function rec() { const { node } = path; if (node.type === "ChainExpression") { - return path.call(() => rec(path), "expression"); + return path.call(rec, "expression"); } if ( @@ -122,7 +122,7 @@ function printMemberChain(path, options, print) { hasTrailingEmptyLine ? hardline : "", ], }); - path.call((callee) => rec(callee), "callee"); + path.call(rec, "callee"); } else if (isMemberish(node)) { printedNodes.unshift({ node, @@ -135,13 +135,13 @@ function printMemberChain(path, options, print) { options, ), }); - path.call((object) => rec(object), "object"); + path.call(rec, "object"); } else if (node.type === "TSNonNullExpression") { printedNodes.unshift({ node, printed: printComments(path, "!", options), }); - path.call((expression) => rec(expression), "expression"); + path.call(rec, "expression"); } else { printedNodes.unshift({ node, @@ -163,7 +163,7 @@ function printMemberChain(path, options, print) { }); if (node.callee) { - path.call((callee) => rec(callee), "callee"); + path.call(rec, "callee"); } // Once we have a linear list of printed nodes, we want to create groups out