Variables declared in a Vue template should be used
- VUE_UNUSED_DECL_IN_TEMPLATE
- Code Quality
- Low
- vue
This rule applies when variables declared in a Vue template are not used.
In a Vue template, variables are declared in the following positions:
v-for
directivesslot-scope
attributes
For maintainability, it is recommended to remove unused variables. Also, it might be a mistake that a programmer forgets to use the declared variables.
Note: Not applied when the variable name starts with _
because we regard it as intentionally unused.
Noncompliant Code Example
View with compliant examples side by side<template>
<div>
<div v-for="(item, index) in items" key="index"> <!-- VUE_UNUSED_DECL_IN_TEMPLATE alarm because variable 'index' is never used. -->
{{ item.value }}
</div>
</div>
</template>
Compliant Code Example
View with noncompliant examples side by side<template>
<div>
<div v-for="(item, index) in items" :key="index">
{{ item.value }}
</div>
</div>
</template>
Version
This rule was introduced in DeepScan 1.15.0-beta.