Skip to content

useSvelteShorthandDirective (HTML)

Language HTML
biome.json
{
"linter": {
"rules": {
"nursery": {
"useSvelteShorthandDirective": "error"
}
}
}
}

Enforce the shorthand syntax for Svelte bind:, class:, and style: directives.

When the value of one of these directives is a variable with the same name as the directive, the value can be omitted: bind:value={value} is the same as bind:value. The shorthand avoids repeating the name and keeps templates shorter.

<input bind:value={value} />
code-block.svelte:1:8 lint/nursery/useSvelteShorthandDirective  FIXABLE  ━━━━━━━━━━━━━━━━━━━━━━━━━━━

ℹ This directive can use the shorthand syntax.

> 1 │ <input bind:value={value} />
│ ^^^^^^^^^^^^^^^^^^
2 │

ℹ The value is a variable with the same name as the directive, so repeating it is redundant.

ℹ This rule belongs to the nursery group, which means it is not yet stable and may change in the future. Visit https://biomejs.dev/linter/#nursery for more information.

ℹ Safe fix: Use the shorthand syntax.

1 │ - <input·bind:value={value}·/>
1 │ + <input·bind:value·/>
2 2 │

<div class:active={active}></div>
code-block.svelte:1:6 lint/nursery/useSvelteShorthandDirective  FIXABLE  ━━━━━━━━━━━━━━━━━━━━━━━━━━━

ℹ This directive can use the shorthand syntax.

> 1 │ <div class:active={active}></div>
│ ^^^^^^^^^^^^^^^^^^^^^
2 │

ℹ The value is a variable with the same name as the directive, so repeating it is redundant.

ℹ This rule belongs to the nursery group, which means it is not yet stable and may change in the future. Visit https://biomejs.dev/linter/#nursery for more information.

ℹ Safe fix: Use the shorthand syntax.

1 │ <div·class:active={active}></div>
│ ---------
<div style:color={color}></div>
code-block.svelte:1:6 lint/nursery/useSvelteShorthandDirective  FIXABLE  ━━━━━━━━━━━━━━━━━━━━━━━━━━━

ℹ This directive can use the shorthand syntax.

> 1 │ <div style:color={color}></div>
│ ^^^^^^^^^^^^^^^^^^^
2 │

ℹ The value is a variable with the same name as the directive, so repeating it is redundant.

ℹ This rule belongs to the nursery group, which means it is not yet stable and may change in the future. Visit https://biomejs.dev/linter/#nursery for more information.

ℹ Safe fix: Use the shorthand syntax.

1 │ <div·style:color={color}></div>
│ --------
<input bind:value />
<input bind:value={name} />
<div class:active></div>
<div class:active={isActive}></div>
<div style:color></div>
<div style:color="red"></div>