Skip to content

valid-v-slot

Reports a v-slot with a modifier, and a v-slot on a plain HTML element (<div #item>). It goes on a <template> or a component. Only in .vue files.

Only a component can receive a slot, so the content on a plain element is lost.

To fix, put the v-slot on a <template> (<template #name="props">) or on the component.

Reported
<template>
...
<b v-for="xs" :key="1" :a="" :a.x="1" #a.m v-if:a="1" @click />
...
<input type="file" v-model="f" /><div v-if="a" #item></div>
<p v-if="ok" :a>
<template #default="p"><C #item="{ a }" /></template>
</p>
...
After the fix
<template>
...
<b v-for="xs" :key="1" :a="" :a.x="1" #a.m v-if:a="1" @click />
...
<input type="file" v-model="f" /><div v-if="a" #item></div>
<p v-if="ok" :a>
<template #default="p"><C #item="{ a }" /></template>
</p>
...
angular:
lint:
rules:
valid-v-slot: warn # off, warn (default), error
html:
lint:
rules:
valid-v-slot: warn # off, warn (default), error
svelte:
lint:
rules:
valid-v-slot: warn # off, warn (default), error
vue:
lint:
rules:
valid-v-slot: warn # off, warn (default), error

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

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