MCPcopy
hub / github.com/prettier/prettier / getCommentTestFunction

Function getCommentTestFunction

src/language-js/utilities/comments.js:33–54  ·  view source on GitHub ↗
(flags, fn)

Source from the content-addressed store, hash-verified

31};
32
33const getCommentTestFunction = (flags, fn) => {
34 if (typeof flags === "function") {
35 fn = flags;
36 flags = 0;
37 }
38 if (flags || fn) {
39 return (comment, index, comments) =>
40 !(
41 (flags & CommentCheckFlags.Leading && !comment.leading) ||
42 (flags & CommentCheckFlags.Trailing && !comment.trailing) ||
43 (flags & CommentCheckFlags.Dangling &&
44 (comment.leading || comment.trailing)) ||
45 (flags & CommentCheckFlags.Block && !isBlockComment(comment)) ||
46 (flags & CommentCheckFlags.Line && !isLineComment(comment)) ||
47 (flags & CommentCheckFlags.First && index !== 0) ||
48 (flags & CommentCheckFlags.Last && index !== comments.length - 1) ||
49 (flags & CommentCheckFlags.PrettierIgnore &&
50 !isPrettierIgnoreComment(comment)) ||
51 (fn && !fn(comment))
52 );
53 }
54};
55/**
56 * @param {Node} node
57 * @param {number | ((comment: Comment) => boolean)} [flags]

Callers 2

hasCommentFunction · 0.85
getCommentsFunction · 0.85

Calls 2

isPrettierIgnoreCommentFunction · 0.90
fnFunction · 0.50

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…