Skip to content

useVueValidVMemo (HTML)

biome.json
{
"linter": {
"rules": {
"nursery": {
"useVueValidVMemo": "error"
}
}
}
}

Enforce valid v-memo Vue directives.

v-memo takes an array of values. Vue skips updating the element and its children until one of those values changes.

This rule reports v-memo directives in the following cases:

  • The directive has an argument. E.g. <div v-memo:aaa="[x]"></div>
  • The directive has a modifier. E.g. <div v-memo.bbb="[x]"></div>
  • The directive has no value, or an empty value. E.g. <div v-memo></div>
  • The directive is on an element inside another element that has v-for. v-memo doesn’t work there. To use v-memo with v-for, put both on the same element.
<div v-memo:aaa="[x]"></div>
code-block.vue:1:12 lint/nursery/useVueValidVMemo ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

✖ The v-memo directive doesn't accept an argument.

> 1 │ <div v-memo:aaa="[x]"></div>
│ ^^^^
2 │

ℹ Remove the argument.

ℹ 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.

<div v-memo.bbb="[x]"></div>
code-block.vue:1:12 lint/nursery/useVueValidVMemo ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

✖ The v-memo directive doesn't support modifiers.

> 1 │ <div v-memo.bbb="[x]"></div>
│ ^^^^
2 │

ℹ Remove the modifiers.

ℹ 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.

<div v-memo></div>
code-block.vue:1:6 lint/nursery/useVueValidVMemo ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

✖ The v-memo directive is missing a value.

> 1 │ <div v-memo></div>
│ ^^^^^^
2 │

ℹ Vue skips updating this element until one of the values in the v-memo array changes.

ℹ Add an array of these values, for example v-memo="[item.id, selected]".

ℹ 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.

<template>
<div v-for="item in items">
<div v-memo="[item.id]"></div>
</div>
</template>
code-block.vue:3:14 lint/nursery/useVueValidVMemo ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

✖ The v-memo directive doesn't work inside an element with v-for.

1 │ <template>
2 │ <div v-for="item in items">
> 3 │ <div v-memo="[item.id]"></div>
│ ^^^^^^
4 │ </div>
5 │ </template>

ℹ To use v-memo with v-for, put both directives on the same element.

ℹ 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.

<template>
<div v-memo="[valueA, valueB]"></div>
<div v-memo="dependencies"></div>
<div v-for="item in items" :key="item.id" v-memo="[item.id === selected]"></div>
</template>