Skip to content

shorthand-directive

Reports bind:name={name}, class:name={name} and style:name={name} where the shorthand (bind:name) would do. The fix writes the shorthand.

The name is written twice for nothing, and one form keeps the components uniform.

To fix, write bind:name; the fix does it.

Reported
...
<svelte:head><title>t</title></svelte:head>
...
<input type="checkbox" bind:value={v} bind:checked={v} id={id} {id} bind:group={group} class:on={on}>
<input bind:value={value} class:big>
...
<C>{#snippet children(x)}{x}{/snippet}</C>
...
After the fix
...
<svelte:head><title>t</title></svelte:head>
...
<input type="checkbox" bind:value={v} bind:checked={v} {id} {id} bind:group class:on>
<input bind:value class:big>
...
<C>{#snippet children(x)}{x}{/snippet}</C>
...
angular:
lint:
rules:
shorthand-directive: warn # off (default), warn, error
html:
lint:
rules:
shorthand-directive: warn # off (default), warn, error
svelte:
lint:
rules:
shorthand-directive: warn # off (default), warn, error
vue:
lint:
rules:
shorthand-directive: warn # off (default), warn, error

Suppress one line with sudsy-disable-next-line shorthand-directive in a comment of the file’s language.

The same check in other tools; Sudsy reports what each upstream rule reports.

Tool Rule Match
eslint-plugin-svelte shorthand-directive full