MCPcopy
hub / github.com/prettier/prettier / genericPrint

Function genericPrint

src/language-css/printer-postcss.js:57–585  ·  view source on GitHub ↗
(path, options, print)

Source from the content-addressed store, hash-verified

55} from "./utilities/index.js";
56
57function genericPrint(path, options, print) {
58 const { node } = path;
59
60 switch (node.type) {
61 case "css-root": {
62 const nodes = printSequence(path, options, print);
63 let after = node.raws.after.trim();
64 if (after.startsWith(";")) {
65 after = after.slice(1).trim();
66 }
67
68 return [
69 node.frontMatter
70 ? [
71 print("frontMatter"),
72 hardline,
73 node.nodes.length > 0 ? hardline : "",
74 ]
75 : "",
76 nodes,
77 after ? ` ${after}` : "",
78 node.nodes.length > 0 ? hardline : "",
79 ];
80 }
81 case "css-comment": {
82 const isInlineComment = node.inline || node.raws.inline;
83
84 const text = options.originalText.slice(locStart(node), locEnd(node));
85
86 return isInlineComment ? text.trimEnd() : text;
87 }
88 case "css-rule":
89 return [
90 print("selector"),
91 node.important ? " !important" : "",
92 node.nodes
93 ? [
94 node.selector?.type === "selector-unknown" &&
95 lastLineHasInlineComment(node.selector.value)
96 ? line
97 : node.selector
98 ? " "
99 : "",
100 "{",
101 node.nodes.length > 0
102 ? indent([hardline, printSequence(path, options, print)])
103 : "",
104 hardline,
105 "}",
106 isDetachedRulesetDeclarationNode(node) ? ";" : "",
107 ]
108 : ";",
109 ];
110
111 case "css-decl": {
112 const parentNode = path.parent;
113
114 const { between: rawBetween } = node.raws;

Callers

nothing calls this directly

Calls 15

locStartFunction · 0.90
locEndFunction · 0.90
lastLineHasInlineCommentFunction · 0.90
indentFunction · 0.90
hasComposesNodeFunction · 0.90
removeLinesFunction · 0.90
shouldBreakListFunction · 0.90
dedentFunction · 0.90
insideIcssRuleNodeFunction · 0.90
maybeToLowerCaseFunction · 0.90
isAtWordPlaceholderNodeFunction · 0.90

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…