vue/require-explicit-slots
eslint-plugin-vue
No autofix
eslint.config.js
import vue from "eslint-plugin-vue";
export default [
{
plugins: { vue },
rules: {
"vue/require-explicit-slots": "error",
},
},
]; <slot name="bar" />
</div>
</template>
<script setup lang="ts">
defineSlots<{
default(props: { msg: string }): any
foo(props: { msg: string }): any
}>()
</script> <slot name="bar" />
</div>
</template>
<script lang="ts">
import { SlotsType } from 'vue'
defineComponent({
slots: Object as SlotsType<{
default: { msg: string }
foo: { msg: string }
}>
})
</script><slot />
<slot name="foo" /><slot />
<slot name="foo" />Examples from the ESLint documentation.
No tracked preset enables this rule, so it has no reach yet.
None of the tracked presets enable this rule. Turn it on with the config below.
vue/require-explicit-slots
eslint-plugin-vue
import vue from "eslint-plugin-vue";
export default [
{
plugins: { vue },
rules: {
"vue/require-explicit-slots": "error",
},
},
];Oxlint does not have this rule.
nursery/noVueUndeclaredSlots
nursery · since 2.6.5
{
"linter": {
"rules": {
"nursery": {
"noVueUndeclaredSlots": "error"
}
}
}
}Require using useTemplateRef instead of ref/shallowRef for template refs
Enforce adding type declarations to object props
Require shorthand form attribute when v-bind value is true