src/language-js/printer-estree.js/printComment
function printComment(commentPath, options) {
  const comment = commentPath.getValue();

  switch (comment.type) {
    case "CommentBlock":
    case "Block": {
      if (isIndentableBlockComment(comment)) {
        const printed = printIndentableBlockComment(comment);
        // We need to prevent an edge case of a previous trailing comment
        // printed as a `lineSuffix` which causes the comments to be
        // interleaved. See https://github.com/prettier/prettier/issues/4412
        if (
          comment.trailing &&
          !hasNewline(options.originalText, options.locStart(comment), {
            backwards: true,
          })
        ) {
          return concat([hardline, printed]);
        }
        return printed;
      }

      const commentEnd = options.locEnd(comment);
      const isInsideFlowComment =
        options.originalText.slice(commentEnd - 3, commentEnd) === "*-/";

      return "/*" + comment.value + (isInsideFlowComment ? "*-/" : "*/");
    }
    case "CommentLine":
    case "Line":
      // Supports `//`, `#!`, `<!--`, and `-->`
      return options.originalText
        .slice(options.locStart(comment), options.locEnd(comment))
        .trimEnd();
    default:
      throw new Error("Not a comment: " + JSON.stringify(comment));
  }
}