Skip to content

no-dupe-on-directives

Reports two on: directives of one element that have the same event and the same handler (modifiers do not count); both are reported.

The handler runs twice for the event, which is rarely meant.

To fix, remove one of them.

Reported
...
<svelte:head><title>t</title></svelte:head>
<input on:click={a} on:click={a} on:click|once={c} use:tip use:tip use:other style:color="a" style:color|important={b}>
...
After the fix
...
<svelte:head><title>t</title></svelte:head>
<input on:click={a} on:click={a} on:click|once={c} use:tip use:tip use:other style:color="a" style:color|important={b}>
...
angular:
lint:
rules:
no-dupe-on-directives: warn # off, warn (default), error
html:
lint:
rules:
no-dupe-on-directives: warn # off, warn (default), error
svelte:
lint:
rules:
no-dupe-on-directives: warn # off, warn (default), error
vue:
lint:
rules:
no-dupe-on-directives: warn # off, warn (default), error

Enabled by the presets: html/eslint-plugin-svelte-recommended.

Suppress one line with sudsy-disable-next-line no-dupe-on-directives 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 no-dupe-on-directives full