Skip to content

📝 HTML: inconsistent closing-slash on void elements #6656

@echocrow

Description

@echocrow

Description

when using "selfCloseVoidElements": "never" (default), seems that the forward slash is not consistently stripped ATM.
the two bugs I'm seeing:

given: <meta foo="bar" />

expected..actual
-<meta foo="bar">
+<meta foo="bar" />

given: <meta foo="bar">

expected..actual
-<meta foo="bar">
+<meta foo="bar" >

oddly enough, this issue seems to only be present on single-line void elements.
when the element has a long list of attributes (forcing multi-line formatting), the trailing slash is correctly stripped.*

* update: looks like formatting of multi-line void elements has its own little bug: currently those may need to be formatted twice to yield the expected result.

specifically, given a long void element starting on a single line and closing with />, the first format split it into multiple lines and keeps the />. then, a subsequent format removes the closing slash, closing it with just > as expected.

should I open a separate issue for this "requires double formatting" bug?

Environment information

CLI:
  Version:                      2.0.6
  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:           v22.14.0
  JS_RUNTIME_NAME:              node
  NODE_PACKAGE_MANAGER:         pnpm/10.7.1

Biome Configuration:
  Status:                       Loaded successfully
  Path:                         biome.json
  Formatter enabled:            true
  Linter enabled:               true
  Assist enabled:               true
  VCS enabled:                  false

Formatter:
  Format with errors:           unset
  Indent style:                 unset
  Indent width:                 unset
  Line ending:                  unset
  Line width:                   unset
  Attribute position:           unset
  Bracket spacing:              unset
  Includes:                     unset

JavaScript Formatter:
  Enabled:                      unset
  JSX quote style:              unset
  Quote properties:             unset
  Trailing commas:              unset
  Semicolons:                   unset
  Arrow parentheses:            unset
  Bracket spacing:              unset
  Bracket same line:            unset
  Quote style:                  unset
  Indent style:                 unset
  Indent width:                 unset
  Line ending:                  unset
  Line width:                   unset
  Attribute position:           unset

JSON Formatter:
  Enabled:                      unset
  Indent style:                 unset
  Indent width:                 unset
  Line ending:                  unset
  Line width:                   unset
  Trailing Commas:              unset
  Expand lists:                 unset

CSS Formatter:
  Enabled:                      unset
  Indent style:                 unset
  Indent width:                 unset
  Line ending:                  unset
  Line width:                   unset
  Quote style:                  unset

GraphQL Formatter:
  Enabled:                      unset
  Indent style:                 unset
  Indent width:                 unset
  Line ending:                  unset
  Line width:                   unset
  Bracket spacing:              unset
  Quote style:                  unset

Workspace:
  Open Documents:               0

Configuration

{
  "$schema": "https://biomejs.dev/schemas/2.0.6/schema.json",
  "html": {
    "formatter": {
      "enabled": true
    }
  }
}

Playground link

https://biomejs.dev/playground/?code=PAAhAGQAbwBjAHQAeQBwAGUAIABoAHQAbQBsAD4ACgA8AGgAdABtAGwAIABsAGEAbgBnAD0AIgBlAG4AIgA%2BAAoACQA8AGgAZQBhAGQAPgAKAAkACQA8AG0AZQB0AGEAIABmAG8AbwA9ACIAYgBhAHIAIgA%2BAAoACQAJADwAbQBlAHQAYQAgAGYAbwBvAD0AIgBiAGEAcgAiACAALwA%2BAAoACgAJAAkAPABtAGUAdABhAAoACQAJAAkAZgBvAG8APQAiAGIAYQByACIACgAJAAkACQBjAG8AbgB0AGUAbgB0AD0AIgB2AGUAcgB5ACAAbABvAG4AZwAgAGEAdAB0AHIAaQBiAHUAdABlAHMAIAB0AG8AIABmAG8AcgBjAGUAIABtAHUAbAB0AGkALQBsAGkAbgBlACAAZgBvAHIAbQBhAHQAdABpAG4AZwAiAAoACQAJAD4ACgAJAAkAPABtAGUAdABhAAoACQAJAAkAZgBvAG8APQAiAGIAYQByACIACgAJAAkACQBjAG8AbgB0AGUAbgB0AD0AIgB2AGUAcgB5ACAAbABvAG4AZwAgAGEAdAB0AHIAaQBiAHUAdABlAHMAIAB0AG8AIABmAG8AcgBjAGUAIABtAHUAbAB0AGkALQBsAGkAbgBlACAAZgBvAHIAbQBhAHQAdABpAG4AZwAiAAoACQAJAC8APgAKACAAIAAgACAAIAAgAAoACQAJADwAbQBlAHQAYQAgAGYAbwBvAD0AIgBiAGEAcgAiACAAYwBvAG4AdABlAG4AdAA9ACIAdgBlAHIAeQAgAGwAbwBuAGcAIABhAHQAdAByAGkAYgB1AHQAZQBzACAAdABvACAAZgBvAHIAYwBlACAAbQB1AGwAdABpAC0AbABpAG4AZQAgAGYAbwByAG0AYQB0AHQAaQBuAGcAIgAgAC8APgAKAAkAPAAvAGgAZQBhAGQAPgAKAAoACQA8AGIAbwBkAHkAPgAKAAkACQA8AGgAMQA%2BAGgAZQBsAGwAbwAgAHcAbwByAGwAZAA8AC8AaAAxAD4ACgAJADwALwBiAG8AZAB5AD4ACgA8AC8AaAB0AG0AbAA%2BAAoA&language=html

Code of Conduct

  • I agree to follow Biome's Code of Conduct

Metadata

Metadata

Assignees

Labels

A-FormatterArea: formatterL-HTMLLanguage: HTML and super languagesS-Bug-confirmedStatus: report has been confirmed as a valid bug

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions