Vize

script/require-prop-types

Require every prop to declare a type

Bad · Good

Default severity: error
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-prop-types": "error"
      }
    },
  },
});
vp run lint

Bad

The array entry declares only the name status; the null value and empty descriptor declare no runtime prop type either.

<script lang="ts">
export default {
props: ['status']            // array form: no types
}

export default {
props: {
status: null,              // no type
other: {}                  // empty descriptor: no type
}
}
</script>

Good

status: String supplies a shorthand constructor, and other supplies type: Number inside its descriptor. Both props now carry type declarations.

<script lang="ts">
export default {
props: {
status: String,
other: { type: Number, default: 0 }
}
}
</script>

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

Implementation · All rules