Skip to content

feat(fmt): use lax-css for formatting CSS, SCSS, and Less files#35160

Draft
bartlomieju wants to merge 3 commits into
mainfrom
feat/lax-css-formatter
Draft

feat(fmt): use lax-css for formatting CSS, SCSS, and Less files#35160
bartlomieju wants to merge 3 commits into
mainfrom
feat/lax-css-formatter

Conversation

@bartlomieju

@bartlomieju bartlomieju commented Jun 11, 2026

Copy link
Copy Markdown
Member

Routes CSS, SCSS, and Less formatting through lax-css instead of malva.
lax-css (https://github.com/bartlomieju/dprint-plugin-css) is built on the
semantics-free parsing model from CSS Syntax Level 3: it never reinterprets
tokens, only adjusts whitespace, so unknown at-rules, Tailwind arbitrary
values, and future syntax format correctly instead of being mangled or
rejected. This fixes the property casing loss in unknown at-rules (#26420)
and the parse error on `::slotted(* + *)` (#34582), neither of which can
be fixed upstream in malva. Author line breaks inside values are preserved,
which also addresses the value collapsing complaints from #29326.

Style blocks in HTML and components and CSS-in-JS tagged templates also go
through lax-css; the `@dpr1nt` placeholders pass through all positions
untouched, so the Less wrapper hack in `format_embedded_css` is gone.
Style attribute contents are kept as written. malva remains only for the
indented Sass syntax, which now prints a deprecation warning; Prettier and
Biome do not support it either. Upgrade churn on files already formatted by
deno fmt is near zero except selector lists, which now always break one per
line like Prettier and Biome.

Fixes #26420
Fixes #34582

Style blocks in HTML and components and CSS-in-JS tagged templates now
go through lax-css as well; the @dpr1nt placeholders pass through all
positions untouched, so the Less wrapper hack is no longer needed.
Style attribute contents are kept as written. malva remains only for
the indented Sass syntax, which now prints a deprecation warning.
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.

Deno fmt crash with Lit css + slotted owl selector fmt does not preserve CSS property casing

1 participant