Skip to content

Fix indentation for rules with an empty selector list - #227

Merged
bartveneman merged 2 commits into
mainfrom
claude/fix-empty-selector-indent
Aug 16, 2026
Merged

Fix indentation for rules with an empty selector list#227
bartveneman merged 2 commits into
mainfrom
claude/fix-empty-selector-indent

Conversation

@bartveneman

Copy link
Copy Markdown
Member

Summary

  • print_rule only added indentation via print_rule_selectors, which pushes one indented line per selector in the selector list.
  • For a malformed/unknown block with zero selectors (e.g. a bare { ... } nested inside another block), no line is pushed at all, so the opening brace's indentation was silently dropped — it printed with a single leading space instead of a tab.
  • Fixed by falling back to indent(depth) when the selector list prints as empty.
  • Updated the test that was pinning the old (buggy) output.

Test plan

  • vitest run — all 254 tests pass
  • tsc --noEmit — no type errors
  • oxlint — clean

Generated by Claude Code

print_rule only indented via print_rule_selectors, which pushes one
indented line per selector. For malformed/unknown blocks with zero
selectors (e.g. a bare `{ }` nested inside another block), no line
was pushed at all, so the opening brace lost its indentation and
printed with a single leading space instead of a tab.
@github-actions

github-actions Bot commented Jul 11, 2026

Copy link
Copy Markdown
Contributor

⚠️ Package Size Increase

📦 Package 📏 Base Size 📏 Source Size 📈 Size Change
@projectwallace/format-css 9.6 kB 9.6 kB +12 B

@bartveneman
bartveneman merged commit 3ff0cbf into main Aug 16, 2026
10 checks passed
@bartveneman
bartveneman deleted the claude/fix-empty-selector-indent branch August 16, 2026 19:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants