Skip to content

noVueReservedKeys

Disallow reserved keys in Vue component data and computed properties.

Vue reserves certain keys for its internal use. Using these reserved keys in data properties, computed properties, methods, or other component options can cause conflicts and unpredictable behavior in your Vue components.

This rule prevents the use of Vue reserved keys such as:

  • Keys starting with $ (e.g., $el, $data, $props, $refs, etc.)
  • Keys starting with _ in data properties (reserved for Vue internals)
<script>
export default {
data: {
$el: '',
},
};
</script>
code-block.vue:3:9 lint/nursery/noVueReservedKeys ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

Key $el is reserved in Vue.

1 │ export default {
2 │ data: {
> 3 │ $el: ”,
^^^
4 │ },
5 │ };

Rename the key to avoid conflicts with Vue reserved keys.

<script>
export default {
data() {
return {
_foo: 'bar',
};
},
};
</script>
code-block.vue:4:13 lint/nursery/noVueReservedKeys ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

Keys starting with an underscore are reserved in Vue.

2 │ data() {
3 │ return {
> 4 │ _foo: ‘bar’,
^^^^
5 │ };
6 │ },

Rename the key to avoid conflicts with Vue reserved keys.

<script>
export default {
computed: {
$data() {
return this.someData;
},
},
};
</script>
code-block.vue:3:9 lint/nursery/noVueReservedKeys ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

Key $data is reserved in Vue.

1 │ export default {
2 │ computed: {
> 3 │ $data() {
^^^^^
4 │ return this.someData;
5 │ },

Rename the key to avoid conflicts with Vue reserved keys.

<script>
export default {
methods: {
$emit() {
// This conflicts with Vue's built-in $emit
},
},
};
</script>
code-block.vue:3:9 lint/nursery/noVueReservedKeys ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

Key $emit is reserved in Vue.

1 │ export default {
2 │ methods: {
> 3 │ $emit() {
^^^^^
4 │ // This conflicts with Vue’s built-in $emit
5 │ },

Rename the key to avoid conflicts with Vue reserved keys.

<script>
export default {
data() {
return {
message: 'Hello Vue!',
count: 0,
};
},
};
</script>
<script>
export default {
computed: {
displayMessage() {
return this.message;
},
},
};
</script>
biome.json
{
"linter": {
"rules": {
"nursery": {
"noVueReservedKeys": "error"
}
}
}
}