From 1413bdf5a34eef39f021941e7411975fe6f12d2b Mon Sep 17 00:00:00 2001 From: Brian Donovan <1938+eventualbuddha@users.noreply.github.com> Date: Fri, 12 May 2023 09:25:55 -0700 Subject: [PATCH] style: apply `prettier` formatting --- lib/comments.ts | 14 +++++++------- test/comments.ts | 39 +++++++++++++++++++++------------------ 2 files changed, 28 insertions(+), 25 deletions(-) diff --git a/lib/comments.ts b/lib/comments.ts index b5958e0b..08e675ae 100644 --- a/lib/comments.ts +++ b/lib/comments.ts @@ -228,15 +228,15 @@ function breakTies(tiesToBreak: any[], lines: any) { ) { ++indexOfFirstLeadingComment; } - + if (indexOfFirstLeadingComment) { - const {enclosingNode} = tiesToBreak[indexOfFirstLeadingComment - 1]; - - if (enclosingNode?.type === 'CallExpression') { - --indexOfFirstLeadingComment; - } + const { enclosingNode } = tiesToBreak[indexOfFirstLeadingComment - 1]; + + if (enclosingNode?.type === "CallExpression") { + --indexOfFirstLeadingComment; + } } - + tiesToBreak.forEach(function (comment, i) { if (i < indexOfFirstLeadingComment) { addTrailingComment(pn, comment); diff --git a/test/comments.ts b/test/comments.ts index e9d6068f..9f4fae87 100644 --- a/test/comments.ts +++ b/test/comments.ts @@ -833,31 +833,34 @@ function runTestsForParser(parserId: any) { ["// comment", ";(function() {})();"].join(eol), ); }); - - pit("should preserve comments attached to CallExpression argument", function () { - const code = 'testFunc (/** @type {string} */ (a), b);'; - const ast = recast.parse(code, { parser }); - const args = ast.program.body[0].expression.arguments; - - args.unshift(args[1]); - const expected = 'testFunc(b, /** @type {string} */ a, b);'; - - assert.strictEqual(recast.print(ast).code, expected); - }); + + pit( + "should preserve comments attached to CallExpression argument", + function () { + const code = "testFunc (/** @type {string} */ (a), b);"; + const ast = recast.parse(code, { parser }); + const args = ast.program.body[0].expression.arguments; + + args.unshift(args[1]); + const expected = "testFunc(b, /** @type {string} */ a, b);"; + + assert.strictEqual(recast.print(ast).code, expected); + }, + ); pit("should preserve comments attached: no enclosed", function () { const code = [ - 'hello.world; // has computed value', - 'hello["world"]; // has computed value', + "hello.world; // has computed value", + 'hello["world"]; // has computed value', ].join(eol); - + const ast = recast.parse(code, { parser }); - + const expected = [ - 'hello.world; // has computed value', - 'hello["world"]; // has computed value', + "hello.world; // has computed value", + 'hello["world"]; // has computed value', ].join(eol); - + assert.strictEqual(recast.print(ast).code, expected); }); }