script/define-props-declaration
Enforce type-based defineProps<{ ... }>() over the runtime/object form
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/define-props-declaration": "warn"
}
},
},
});
vp run lint
Bad
defineProps({ title: String }) supplies a runtime object, which conflicts with this rule’s preference for type-based props.
<script setup lang="ts">
const props = defineProps({ title: String });
console.log(props.title);
</script>
Good
defineProps<{ title: string }>() declares title in the type argument and retains the props.title access without a runtime declaration argument.
<script setup lang="ts">
const props = defineProps<{ title: string }>();
console.log(props.title);
</script>
Good avoids this rule's finding under the configuration above; other rules may still report diagnostics.