Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions .changeset/rotten-pans-ring.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
---
"@biomejs/biome": patch
---

Fixed an issue with the HTML formatter where it wouldn't add a space before the `/>` in self closing elements. This brings the HTML formatter more in line with Prettier.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

Hyphenate "self-closing".

The term should be "self-closing" with a hyphen.

🔎 Proposed fix
-Fixed an issue with the HTML formatter where it wouldn't add a space before the `/>` in self closing elements. This brings the HTML formatter more in line with Prettier.
+Fixed an issue with the HTML formatter where it wouldn't add a space before the `/>` in self-closing elements. This brings the HTML formatter more in line with Prettier.
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
Fixed an issue with the HTML formatter where it wouldn't add a space before the `/>` in self closing elements. This brings the HTML formatter more in line with Prettier.
Fixed an issue with the HTML formatter where it wouldn't add a space before the `/>` in self-closing elements. This brings the HTML formatter more in line with Prettier.
🧰 Tools
🪛 LanguageTool

[misspelling] ~5-~5: This word is normally spelled with a hyphen.
Context: ...wouldn't add a space before the /> in self closing elements. This brings the HTML formatte...

(EN_COMPOUNDS_SELF_CLOSING)

🤖 Prompt for AI Agents
In .changeset/rotten-pans-ring.md around line 5, the phrase "self closing
elements" should be hyphenated; change it to "self-closing elements" so the
changelog uses the correct term and punctuation.


```diff
-<Component/>
+<Component />
```
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,9 @@ impl FormatNodeRule<HtmlSelfClosingElement> for FormatHtmlSelfClosingElement {
// To resolve this, these tokens either need to be passed to or deferred to sibling text elements when
// whitespace sensitivity would require it.
if slash_token.is_some() {
write!(f, [slash_token.format()])?;
write!(f, [if_group_fits_on_line(&space()), slash_token.format()])?;
} else {
write!(f, [token("/")])?;
write!(f, [if_group_fits_on_line(&space()), token("/")])?;
}
}
// We remove the slash only from void elements
Expand All @@ -67,6 +67,10 @@ impl FormatNodeRule<HtmlSelfClosingElement> for FormatHtmlSelfClosingElement {
write!(f, [format_removed(slash_token)])?;
}
} else {
if slash_token.is_some() {
// only add a space before the slash if it exists.
write!(f, [space()])?;
}
write!(f, [slash_token.format()])?;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ import Button from './Button.astro';
import TextInput from './TextInput.astro';
---

<Button label="test button"/>
<TextInput placeholder="enter text"/>
<Button label="test button" />
<TextInput placeholder="enter text" />
<button>native button</button>
<input type="text">
```
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<Button
label="test button"
variant="primary"
size="lg"
class="text-2xl bg-amber-600 font-bold"
/>
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
---
source: crates/biome_formatter_test/src/snapshot_builder.rs
info: component-frameworks/large-self-closing.svelte
---
# Input

```svelte
<Button
label="test button"
variant="primary"
size="lg"
class="text-2xl bg-amber-600 font-bold"
/>

```


=============================

# Outputs

## Output 1

-----
Indent style: Tab
Indent width: 2
Line ending: LF
Line width: 80
Attribute Position: Auto
Bracket same line: false
Whitespace sensitivity: css
Indent script and style: false
Self close void elements: never
-----

```svelte
<Button
label="test button"
variant="primary"
size="lg"
class="text-2xl bg-amber-600 font-bold"
/>
```
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,9 @@ Self close void elements: never
import Select from './Select.svelte';
</script>

<Button label="test button"/>
<TextInput placeholder="enter text"/>
<Select options={['a', 'b']}/>
<Button label="test button" />
<TextInput placeholder="enter text" />
<Select options={['a', 'b']} />
<button>native button</button>
<input type="text">
<select>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ import TextInput from './TextInput.vue';
</script>

<template>
<Button label="test button"/>
<TextInput placeholder="enter text"/>
<Button label="test button" />
<TextInput placeholder="enter text" />
<button>native button</button>
</template>
```
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,6 @@ Self close void elements: never

```svelte
{#await import('./Component.svelte') then { default: Component }}
<Component/>
<Component />
{/await}
```
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,5 @@ Self close void elements: never
-----

```vue
<Foo @update:modelValue="onUpdate"/>
<Foo @update:modelValue="onUpdate" />
```
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,6 @@ Self close void elements: never
-----

```vue
<Component v-if="operation" :property="123"/>
<Component v-else :property="123"/>
<Component v-if="operation" :property="123" />
<Component v-else :property="123" />
```