diff --git a/src/lib/index.ts b/src/lib/index.ts index 515d26f..0481d60 100644 --- a/src/lib/index.ts +++ b/src/lib/index.ts @@ -564,6 +564,12 @@ export function format( if (node.has_prelude && is_selector_list(node.prelude)) { let list = print_rule_selectors(node.prelude) + // An empty selector list (malformed/unknown block) prints no selector + // lines, so the indentation that print_rule_selectors would normally add + // per-selector has to be added here instead. + if (list === EMPTY_STRING) { + list = indent(depth) + } let comment = get_comment(node.first_child?.end, node.block?.start) if (comment) { diff --git a/test/rules.test.ts b/test/rules.test.ts index 32ba894..6500b28 100644 --- a/test/rules.test.ts +++ b/test/rules.test.ts @@ -176,7 +176,7 @@ test('formats unknown stuff in curly braces', () => { } `) let expected = `selector { - { + { color: red; } }`