script/require-prop-type-constructor
Require prop type values to be constructors rather than string literals
Default severity: error
Presets: essential, happy-path, ecosystem, nuxt, opinionated
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-prop-type-constructor": "error"
}
},
},
});
vp run lint
Bad
The prop declarations use strings "String" and "Number" as runtime types, including inside the constructor array. Those strings are not constructor functions.
<script lang="ts">
export default {
props: {
// The type should be the `String` constructor, not the string "String".
name: "String",
age: { type: "Number" },
id: { type: ["String", "Number"] }
}
}
</script>
Good
The declarations use the actual String and Number identifiers, including the union array [String, Number].
<script lang="ts">
export default {
props: {
name: String,
age: { type: Number },
id: { type: [String, Number] }
}
}
</script>
Good avoids this rule's finding under the configuration above; other rules may still report diagnostics.