Skip to content

require-prop-types

Reports a prop in the array form (defineProps(['a'])), and an object with no type or validator.

A prop with no type accepts anything, so a wrong value is shown only as a failure far from the cause, and the component has no documentation of what it takes.

To fix, write the prop as an object with a type.

Reported
...
c: { required: true, type: Number },
d: Boolean,
...
f: {},
...
},
data() {
...
</script>
<script setup>
defineProps(['x', 'y'])
const ok = 1
const model = defineModel()
</script>
angular:
lint:
rules:
require-prop-types: warn # off, warn (default), error
html:
lint:
rules:
require-prop-types: warn # off, warn (default), error
svelte:
lint:
rules:
require-prop-types: warn # off, warn (default), error
vue:
lint:
rules:
require-prop-types: warn # off, warn (default), error

Enabled by the presets: html/eslint-plugin-vue-recommended.

Suppress one line with sudsy-disable-next-line require-prop-types in a comment of the file’s language.

The same check in other tools. full: Sudsy reports what the upstream rule reports; partial: only part of it, as the last column says.

Tool Rule Match What differs
eslint-plugin-vue require-prop-types partial a type it cannot resolve in the file is skipped, a component object only at the top level as for no-dupe-keys