MCPcopy
hub / github.com/prettier/prettier / assertComments

Function assertComments

src/language-js/parse/postprocess/index.js:240–262  ·  view source on GitHub ↗
(comments, text)

Source from the content-addressed store, hash-verified

238
239/* c8 ignore next */
240function assertComments(comments, text) {
241 for (const comment of comments) {
242 const commentText = text.slice(locStart(comment), locEnd(comment));
243
244 if (isLineComment(comment)) {
245 const openingMark = text.slice(
246 0,
247 text.startsWith("<--") || text.startsWith("-->") ? 3 : 2,
248 );
249 assert.ok(openingMark + comment.value, commentText);
250 return;
251 }
252
253 if (isBlockComment(comment)) {
254 // Flow
255 const closingMark = commentText.endsWith("*-/") ? "*-/" : "*/";
256 assert.equal("/*" + comment.value + closingMark, commentText);
257 return;
258 }
259
260 throw new Error(`Unknown comment type '${comment.type}'.`);
261 }
262}
263
264/* c8 ignore next */
265function assertRaw(node, text) {

Callers 1

postprocessFunction · 0.85

Calls 2

locStartFunction · 0.90
locEndFunction · 0.90

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…