Skip to content

Commit 9419ded

Browse files
committed
feature: @putout/printer: hasTrailingCommentsPrinter
1 parent c401583 commit 9419ded

1 file changed

Lines changed: 17 additions & 4 deletions

File tree

lib/tokenize/comment/comments-printer/comments-printer.js

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,27 @@ const createPrintCommentLine = (fn, value) => () => fn(`//${value}`);
44
const createPrintCommentBlock = (fn, value) => () => fn(`/*${value}*/\n`);
55

66
module.exports.hasTrailingCommentsPrinter = (currentTraverse) => {
7-
const {printTrailingCommentBlock} = currentTraverse;
7+
const {
8+
printTrailingCommentBlock,
9+
printTrailingCommentLine,
10+
} = currentTraverse;
11+
12+
if (printTrailingCommentBlock)
13+
return true;
814

9-
return Boolean(printTrailingCommentBlock);
15+
return Boolean(printTrailingCommentLine);
1016
};
1117

1218
module.exports.hasLeadingCommentsPrinter = (currentTraverse) => {
13-
const {printLeadingCommentLine} = currentTraverse;
19+
const {
20+
printLeadingCommentLine,
21+
printLeadingCommentBlock,
22+
} = currentTraverse;
1423

15-
return Boolean(printLeadingCommentLine);
24+
if (printLeadingCommentLine)
25+
return true;
26+
27+
return Boolean(printLeadingCommentBlock);
1628
};
1729

1830
module.exports.printLeadingComments = (path, printer, semantics, {currentTraverse}) => {
@@ -76,3 +88,4 @@ module.exports.printTrailingComments = (path, printer, semantics, {currentTraver
7688
});
7789
}
7890
};
91+

0 commit comments

Comments
 (0)