Skip to content

Commit 03721d5

Browse files
committed
using destructuring when possible
1 parent 1474ca2 commit 03721d5

5 files changed

Lines changed: 7 additions & 7 deletions

File tree

src/slang-comments/printer.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import type { AstPath, Doc } from 'prettier';
44
import type { AstNode } from '../slang-nodes/types.d.ts';
55

66
export function printComment(commentPath: AstPath<AstNode>): Doc {
7-
const comment = commentPath.node;
7+
const { node: comment } = commentPath;
88

99
if (isComment(comment)) {
1010
return comment.print();

src/slang-printers/print-binary-operation.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ export const binaryIndentRulesBuilder =
4444
(shouldIndent: (node: BinaryOperation) => boolean) =>
4545
(path: AstPath<BinaryOperation>) =>
4646
(document: Doc): Doc => {
47-
let node = path.node;
47+
let { node } = path;
4848
for (let i = 2; ; i += 2) {
4949
const grandparentNode = path.getNode(i) as StrictAstNode;
5050
if (shouldNotIndent(grandparentNode, path, i)) break;

src/slang-printers/print-comments.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ export function printComments(path: AstPath<AstNode>): Doc[] {
1212
const document = joinExisting(
1313
line,
1414
path.map((commentPath) => {
15-
const comment = commentPath.node;
15+
const { node: comment } = commentPath;
1616
if (comment.trailing || comment.leading || comment.printed) {
1717
return '';
1818
}

src/slang-printers/print-logical-operation.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ const logicalGroupRulesBuilder = binaryGroupRulesBuilder(() => false);
2121
const logicalIndentRulesBuilder =
2222
(path: AstPath<BinaryOperation>, options: ParserOptions<AstNode>) =>
2323
(document: Doc): Doc => {
24-
let node = path.node;
24+
let { node } = path;
2525
for (let i = 2; ; i += 2) {
2626
const grandparentNode = path.getNode(i) as StrictAstNode;
2727
if (shouldNotIndent(grandparentNode, path, i)) break;

src/slangPrinter.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ function hasNodeIgnoreComment(node: StrictAstNode): boolean {
2020
}
2121

2222
function ignoreComments(path: AstPath<AstNode>): void {
23-
const node = path.node;
23+
const { node } = path;
2424
// We ignore anything that is not an object
2525
if (node === null || typeof node !== 'object') return;
2626

@@ -36,7 +36,7 @@ function ignoreComments(path: AstPath<AstNode>): void {
3636
// The key `comments` will contain every comment for this node
3737
case 'comments':
3838
path.each((commentPath) => {
39-
const comment = commentPath.node;
39+
const { node: comment } = commentPath;
4040
comment.printed = true;
4141
}, 'comments');
4242
break;
@@ -61,7 +61,7 @@ function genericPrint(
6161
options: ParserOptions<AstNode>,
6262
print: PrintFunction
6363
): Doc {
64-
const node = path.node;
64+
const { node } = path;
6565

6666
if (node === null) {
6767
return '';

0 commit comments

Comments
 (0)