Skip to content

Commit 62bf068

Browse files
committed
printer: Extract hasPrettierIgnoreComment() helper
1 parent 4e9cdc4 commit 62bf068

1 file changed

Lines changed: 10 additions & 6 deletions

File tree

src/printer.js

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -49,18 +49,22 @@ function shouldPrintComma(options, level) {
4949
}
5050
}
5151

52+
function hasPrettierIgnoreComment(node) {
53+
return (
54+
node &&
55+
node.comments &&
56+
node.comments.length > 0 &&
57+
node.comments.some(comment => comment.value.trim() === "prettier-ignore")
58+
);
59+
}
60+
5261
function genericPrint(path, options, printPath, args) {
5362
assert.ok(path instanceof FastPath);
5463

5564
var node = path.getValue();
5665

5766
// Escape hatch
58-
if (
59-
node &&
60-
node.comments &&
61-
node.comments.length > 0 &&
62-
node.comments.some(comment => comment.value.trim() === "prettier-ignore")
63-
) {
67+
if (hasPrettierIgnoreComment(node)) {
6468
return options.originalText.slice(util.locStart(node), util.locEnd(node));
6569
}
6670

0 commit comments

Comments
 (0)