Design system · UI
DS0009Write Component Contracts as literals
Finds `defineOptions({ doctor })` values Doctor cannot read as a Component Contract.
vite-doctor/design-systemuiwarnSuggestion
Why it happens
Doctor reads Component Contracts statically from the SFC. A variable, function call, or unknown key in the doctor option leaves the contract unread, so design-system/prefer-project-component cannot point raw elements to the component and design-system/limit-per-view cannot count its usages. A limit that misses max, why, or fix, or whose fix repeats its why, is unreadable too.
Fix
Write the doctor option as a literal object, such as defineOptions({ doctor: { replaces: "button" } }).
Example
Write the contract as a literal
Before
<script setup lang="ts">
const element = "button";
defineOptions({ doctor: { replaces: element } });
</script>
<template>
<button class="app-button"><slot /></button>
</template>
After
<script setup lang="ts">
defineOptions({ doctor: { replaces: "button" } });
</script>
<template>
<button class="app-button"><slot /></button>
</template>
Verify the fix
Run only this rule after editing so the report stays focused on the diagnostic you are closing:
pnpm vite-doctor . --extends design-system/strict --rules design-system/unreadable-contract