Vue

vue/detailed-props

Declare props with their types (an object with type, or a TypeScript type), not as a bare array of names.

minorstaticfe-vue

Why

defineProps(['status', 'items']) accepts anything: a string where an array was expected reaches the template and fails there, far from the caller. The component's contract is not written anywhere, and editors cannot help the next person who uses it.

Fix

Use the type-based declaration in TypeScript (defineProps<{ status: 'open' | 'closed'; items: Item[] }>()) or the object form with type, required and, where useful, validator. Give optional props defaults with withDefaults or destructuring defaults (Vue 3.5).

Examples

// bad
const props = defineProps(['status'])
// good
const props = defineProps({ status: { type: String, required: true, validator: (v) => ['open', 'closed'].includes(v) } })

Sources

Facts

Id
vue/detailed-props
Severity
minor
Check
static checked in the source by audit
Applies to
vue
Only in projects with
vue nuxt
Taught by the skill
fe-vue Vue components
Since version
0.1.0

Rule file on GitHub

Read it in the terminal

npx github:dawidolko/frontend-skills explain vue/detailed-props