useSvelteShorthandDirective (HTML)
Language HTML
Summary
Section titled “Summary”- Rule available since:
v2.6.0 - Diagnostic Category:
lint/nursery/useSvelteShorthandDirective - This rule has a safe fix.
- The default severity of this rule is information.
- This rule belongs to the following domains:
- Sources:
- Same as
svelte/shorthand-directive
- Same as
How to configure
Section titled “How to configure”{ "linter": { "rules": { "nursery": { "useSvelteShorthandDirective": "error" } } }}Description
Section titled “Description”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.
Examples
Section titled “Examples”Invalid
Section titled “Invalid”<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>Related links
Section titled “Related links”Copyright (c) 2023-present Biome Developers and Contributors.