Skip to content

noSvelteLegacyConst (HTML)

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

Disallow legacy Svelte {@const} tags.

Declaration tags provide the current syntax for deriving values in Svelte markup (available since Svelte 5.56).

{#each boxes as box}
{@const area = box.width * box.height}
<p>{area}</p>
{/each}
code-block.svelte:2:5 lint/nursery/noSvelteLegacyConst ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

Avoid legacy Svelte {@const} tags.

1 │ {#each boxes as box}
> 2 │ {@const area = box.width * box.height}
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
3 │ <p>{area}</p>
4 │ {/each}

{@const} legacy syntax is less versatile. Declaration tags are the preferred syntax for deriving values in Svelte markup.

Remove the @ and add $state() or $derived() runes if the value should be reactive, for example: {const area = $derived(box.width * box.height)}.

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.

{#each boxes as box}
{const area = $derived(box.width * box.height)}
<p>{area}</p>
{/each}