Vize

script/require-explicit-slots

Require slots consumed via useSlots() to be explicitly typed with defineSlots<...>()

Bad · Good

Default severity: warning
Presets: none
Automatic fix: None; review the suggested change
Applies to: JS/TS scripts in Vue SFCs; examples show the relevant Options API or script setup form
Options: No rule-specific options. Severity and preset selection are configurable.

Configuration (Vite+)

import { defineConfig } from "@vizejs/vite-plugin/vite-plus";

export default defineConfig({
  lint: {
    vize: {
      "preset": "incremental",
      "rules": {
        "script/require-explicit-slots": "warn"
      }
    },
  },
});
vp run lint

Bad

The typed defineProps<{ id: number }>() establishes TypeScript syntax, but setup uses useSlots() without a defineSlots declaration. The rule therefore finds consumed slots without an explicit slot contract.

<script setup lang="ts">
const props = defineProps<{ id: number }>()
const slots = useSlots()
</script>

Good

defineSlots declares a default slot whose props include msg: string; useSlots() now appears alongside an explicit typed slot contract.

<script setup lang="ts">
defineSlots<{ default(props: { msg: string }): unknown }>()
const slots = useSlots()
</script>

Good avoids this rule's finding under the configuration above; other rules may still report diagnostics.

Implementation · All rules