MCPcopy
hub / github.com/prettier/prettier / printExpressionStatement

Function printExpressionStatement

src/language-js/print/expression-statement.js:48–75  ·  view source on GitHub ↗
(path, options, print)

Source from the content-addressed store, hash-verified

46}
47
48function printExpressionStatement(path, options, print) {
49 /** @type {Doc[]} */
50 const parts = [print("expression")];
51
52 if (shouldExpressionStatementPrintLeadingSemicolon(path, options)) {
53 if (shouldExpressionStatementPrintOwnComments(path, options)) {
54 const { node } = path;
55 const typeCastComment = getComments(node, CommentCheckFlags.Leading).at(
56 -1,
57 );
58
59 // Print the type cast comment separately and print `;` before it
60 const typeCastCommentDoc = printLeadingComments(path, options, {
61 filter: (comment) => comment === typeCastComment,
62 });
63
64 return printComments(path, [";", typeCastCommentDoc, ...parts], options, {
65 filter: (comment) => comment !== typeCastComment,
66 });
67 }
68
69 parts.unshift(";");
70 } else if (shouldPrintSemicolon(path, options)) {
71 parts.push(";");
72 }
73
74 return parts;
75}
76
77export { printExpressionStatement };

Callers 1

printEstreeFunction · 0.90

Calls 8

getCommentsFunction · 0.90
printLeadingCommentsFunction · 0.90
printCommentsFunction · 0.90
shouldPrintSemicolonFunction · 0.85
atMethod · 0.80
printFunction · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…