MCPcopy Index your code
hub / github.com/darkreader/darkreader / formatStyleRule

Function formatStyleRule

src/utils/css-text/format-css.ts:27–37  ·  view source on GitHub ↗
({selectors, declarations}: ParsedStyleRule, indent: string)

Source from the content-addressed store, hash-verified

25 }
26
27 function formatStyleRule({selectors, declarations}: ParsedStyleRule, indent: string) {
28 const lastSelectorIndex = selectors.length - 1;
29 selectors.forEach((selector, i) => {
30 lines.push(`${indent}${selector}${i < lastSelectorIndex ? ',' : ' {'}`);
31 });
32 const sorted = sortDeclarations(declarations);
33 sorted.forEach(({property, value, important}) => {
34 lines.push(`${indent}${tab}${property}: ${value}${important ? ' !important' : ''};`);
35 });
36 lines.push(`${indent}}`);
37 }
38
39 clearEmptyRules(parsed);
40 parsed.forEach((rule) => formatRule(rule, ''));

Callers 1

formatRuleFunction · 0.85

Calls 1

sortDeclarationsFunction · 0.85

Tested by

no test coverage detected