Skip to content

useVueConsistentDefinePropsDeclaration (JavaScript)

Language JavaScript (and super languages)
biome.json
{
"linter": {
"rules": {
"style": {
"useVueConsistentDefinePropsDeclaration": "error"
}
}
}
}

Enforce a consistent declaration style for Vue’s defineProps macro.

Vue accepts two ways to declare component properties: a TypeScript type passed between angle brackets, or a runtime object passed as an argument. This rule enforces one style throughout the project. The default style is type.

<script setup lang="ts">
const props = defineProps({
kind: { type: String },
});
</script>
code-block.vue:2:15 lint/style/useVueConsistentDefinePropsDeclaration ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

ℹ This defineProps declaration uses runtime declaration.

1 │ <script setup lang="ts">
> 2 │ const props = defineProps({
│ ^^^^^^^^^^^^^
> 3 │ kind: { type: String },
> 4 │ });
│ ^^
5 │ </script>
6 │

ℹ It should be defined using type declaration like defineProps<...>().

<script setup lang="ts">
const props = defineProps<{
kind: string;
}>();
</script>

Selects type or runtime declarations. Defaults to type.

biome.json
{
"linter": {
"rules": {
"style": {
"useVueConsistentDefinePropsDeclaration": {
"level": "on",
"options": {
"style": "runtime"
}
}
}
}
}
}

With runtime, a type-based declaration is invalid:

<script setup lang="ts">
const props = defineProps<{ kind: string }>();
</script>
code-block.vue:2:15 lint/style/useVueConsistentDefinePropsDeclaration ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

ℹ This defineProps declaration uses type declaration.

1 │ <script setup lang="ts">
> 2 │ const props = defineProps<{ kind: string }>();
│ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
3 │ </script>
4 │

ℹ It should be defined using runtime declaration like defineProps(...).

A runtime declaration is valid:

<script setup lang="ts">
const props = defineProps({ kind: { type: String } });
</script>