Skip to content

fix: correctly print atrule preludes without regexes - #255

Draft
bartveneman wants to merge 4 commits into
mainfrom
claude/eloquent-tesla-um0olt
Draft

bartveneman wants to merge 4 commits into
mainfrom
claude/eloquent-tesla-um0olt

Conversation

@bartveneman

Copy link
Copy Markdown
Member

closes #230

@github-actions

github-actions Bot commented Oct 21, 2026 •

Copy link
Copy Markdown
Contributor

⚠️ Package Size Increase

📦 Package 📏 Base Size 📏 Source Size 📈 Size Change
@projectwallace/format-css 9.3 kB 10.6 kB +1.3 kB

bartveneman added a commit that referenced this pull request Oct 21, 2026
## Summary
- Bumps `@projectwallace/css-parser` from `^0.18.12` to `^0.19.0`
(`package.json` and `pnpm-lock.yaml`).
- 0.19.0 changes the argument order of the string helpers:
`str_index_of` and `str_starts_with` now take the lowercase needle
first, like `str_equals`. TypeScript can't flag this because both
signatures are `(string, string)`.
- The only affected call site on `main` is `str_index_of(prelude,
'selector(')` in `format_atrule_prelude`, now `str_index_of('selector(',
prelude)`. The `str_equals` calls already used this order.
- Split out of #255 to keep that PR focused; #255 builds on this change.

## Test plan
- [x] `vitest run` passes (277 passed, 1 skipped)
- [x] `tsc` clean
- [x] `oxlint` / `oxfmt --check` clean

---

---
_Generated by [Claude
Code](https://claude.ai/code/session_01KUTjbYYHYCyZ6FTyXrqGHX)_

Co-authored-by: Claude <noreply@anthropic.com>
Print @media, @container, @supports, @layer, @scope and @import preludes from
the parsed AST instead of regex replacements. Preludes that are not conditions
(@page, @namespace, @document, @custom-selector, @function,
@font-feature-values) are only whitespace- and comma-normalized, keeping
strings, urls, colons and type tokens intact. Selectors in @scope are formatted.
Adds extensive at-rule tests.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@bartveneman
bartveneman force-pushed the claude/eloquent-tesla-um0olt branch from 0584cf7 to 4acaef9 Compare October 21, 2026 19:14
Test-drives css-parser@22acfdc (pkg.pr.new preview), where PreludeSelectorList
has a parsed SelectorList child. Drops the re-parse of node.value.
Switch the dependency to the released version before merging.
@bartveneman
bartveneman marked this pull request as draft October 21, 2026 19:22
@namespace now prints from its parsed children. Preludes the parser only gives us
as Raw (@page, @document, @custom-selector, @function, @font-feature-values) are
walked token by token, which keeps strings intact without placeholder regexes.
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