-
-
Notifications
You must be signed in to change notification settings - Fork 792
Description
I'm filing this as a follow-up to #4927
I'm glad to see that Biome 2.0 stable includes an HTML formatter, but I am shocked to find that its default configuration breaks the layout of pages.
Specifically, it seems that whitespaceSensitivity is set to "ignore" by default. From my perspective, I consider this to be a severe bug.
For comparison, Biome is conservative when formatting JS files. Fixes are categorized as unsafe even if they are "obviously correct" in the vast majority of JS programs. In the same way, I think it should be a high-level goal of Biome's HTML formatter not to break:
- the parsed DOM content of the page, or
- the layout of the page.
HTML whitespace sensitivity is quirky at best, but it is well-established. I have often had to write code that relies on it, and I am certain a lot of people are maintaining projects that rely on it due to:
- code they have intentionally written this way,
- code they have written this way that accidentally relies on whitespace semantics,
- code that they are maintaining but have not written,
- snippets that were pasted because they "just work",
- etc.
If Biome ships HTML formatting with its current whitespaceSensitivity, I cannot in good conscience recommend it as a formatter. Speaking from experience, I fully expect that this will silently break projects that migrate to Biome, leading to confusion and frustration at chasing down subtle layout bugs.
As an alternative, I would like to suggest to:
- Change the default to either
"css"or"strict". (I haven't yet looked into which is sufficiently safe.) - Maybe introduce a warning to the effect of:
Biome encountered HTML that cannot be pretty-formatted without affecting the layout or parsing of the page. Consider specifying an explicit value of
whitespaceSensitivityto avoid this message. For more details, consult: (link to documentation page with examples)
Environment information
CLI:
Version: 2.0.0
Color support: true
Platform:
CPU Architecture: aarch64
OS: macos
Environment:
BIOME_LOG_PATH: unset
BIOME_LOG_PREFIX_NAME: unset
BIOME_CONFIG_PATH: unset
BIOME_THREADS: unset
NO_COLOR: unset
TERM: xterm-256color
JS_RUNTIME_VERSION: v24.2.0
JS_RUNTIME_NAME: node
NODE_PACKAGE_MANAGER: bun/1.2.15
Biome Configuration:
Status: Loaded successfully
Path: biome.json
Formatter enabled: true
Linter enabled: true
Assist enabled: true
VCS enabled: true
Workspace:
Open Documents: 0Playground link
Code of Conduct
- I agree to follow Biome's Code of Conduct