Skip to content

valid-v-on

Reports a v-on with no handler and no modifier (@click). @click.prevent alone is not reported.

A listener with no handler does nothing, so the click, or the key, has no effect.

To fix, write @click="go".

Reported
<template>
...
<b v-for="xs" :key="1" :a="" :a.x="1" #a.m v-if:a="1" @click />
...
<p v-if="ok" :a>
...
After the fix
<template>
...
<b v-for="xs" :key="1" :a="" :a.x="1" #a.m v-if:a="1" @click />
...
<p v-if="ok" :a>
...
angular:
lint:
rules:
valid-v-on: warn # off, warn (default), error
html:
lint:
rules:
valid-v-on: warn # off, warn (default), error
svelte:
lint:
rules:
valid-v-on: warn # off, warn (default), error
vue:
lint:
rules:
valid-v-on: warn # off, warn (default), error

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

Suppress one line with sudsy-disable-next-line valid-v-on 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-vue valid-v-on full