Skip to content

noVueExcessiveProps (JavaScript)

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

Limit the number of props a Vue component can declare.

A component with many props usually does too many things. Each prop is another input that the component has to handle and that its users have to understand. Splitting the component into smaller components keeps each of them easier to read, use, and test.

This rule counts the props declared with the props option, and with defineProps() in <script setup>. A prop name that is declared more than once is counted once.

The rule only counts props whose names it can read. For example, it can’t count props declared with a spread (...sharedProps), or with a type imported from another file.

The examples below set maxProps to 2.

biome.json
{
"linter": {
"rules": {
"nursery": {
"noVueExcessiveProps": {
"level": "on",
"options": {
"maxProps": 2
}
}
}
}
}
}
<script setup lang="ts">
defineProps<{
title: string;
subtitle: string;
icon: string;
}>();
</script>
code-block.vue:3:3 lint/nursery/noVueExcessiveProps ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

ℹ This component declares too many props (3). The maximum allowed is 2.

1 │ <script setup lang="ts">
2 │ defineProps<{
> 3 │ title: string;
│ ^^^^^^^^^^^^^^
> 4 │ subtitle: string;
> 5 │ icon: string;
│ ^^^^^^^^^^^^^
6 │ }>();
7 │ </script>

ℹ Each prop is another input that the component has to handle, which makes it harder to read, use, and test.

ℹ Split the component into smaller components that each need fewer props.

ℹ This rule belongs to the nursery group, which means it is not yet stable and may change in the future. Visit https://biomejs.dev/linter/#nursery for more information.

<script>
export default {
props: {
title: String,
subtitle: String,
icon: String,
},
};
</script>
code-block.vue:4:5 lint/nursery/noVueExcessiveProps ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

ℹ This component declares too many props (3). The maximum allowed is 2.

2 │ export default {
3 │ props: {
> 4 │ title: String,
│ ^^^^^^^^^^^^^^
> 5 │ subtitle: String,
> 6 │ icon: String,
│ ^^^^^^^^^^^^
7 │ },
8 │ };

ℹ Each prop is another input that the component has to handle, which makes it harder to read, use, and test.

ℹ Split the component into smaller components that each need fewer props.

ℹ This rule belongs to the nursery group, which means it is not yet stable and may change in the future. Visit https://biomejs.dev/linter/#nursery for more information.

<script setup>
defineProps(["title", "subtitle"]);
</script>

Default: 10

The maximum number of props a component can declare. It must be at least 1.

biome.json
{
"linter": {
"rules": {
"nursery": {
"noVueExcessiveProps": {
"level": "on",
"options": {
"maxProps": 1
}
}
}
}
}
}
<script setup>
defineProps({
title: String,
subtitle: String,
});
</script>
code-block.vue:3:3 lint/nursery/noVueExcessiveProps ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

ℹ This component declares too many props (2). The maximum allowed is 1.

1 │ <script setup>
2 │ defineProps({
> 3 │ title: String,
│ ^^^^^^^^^^^^^^
> 4 │ subtitle: String,
│ ^^^^^^^^^^^^^^^^
5 │ });
6 │ </script>

ℹ Each prop is another input that the component has to handle, which makes it harder to read, use, and test.

ℹ Split the component into smaller components that each need fewer props.

ℹ This rule belongs to the nursery group, which means it is not yet stable and may change in the future. Visit https://biomejs.dev/linter/#nursery for more information.

<script setup>
defineProps({
title: String,
});
</script>