JS.VUE.NO.UNUSED.VARS

Disallow unused variable definitions of v-for directives or scope attributes

  • Some problems reported by this rule are manually fixable by editor suggestions (https://eslint.org/docs/developer-guide/working-with-rules#providing-suggestions).

Rule Details

This rule report variable definitions of v-for directives or scope attributes if those are not used.

{'vue/no-unused-vars': ['error']}

Copy
<template>
  <!-- GOOD -->
  <ol v-for="i in 5">
    <li>{{ i }}</li>
  </ol>

  <!-- BAD -->
  <ol v-for="i in 5">
    <li>item</li>
  </ol>
</template>

Options

Copy
{
    "vue/no-unused-vars": ["error", {
        "ignorePattern": "^_"
    }]
}
  • ignorePattern ... disables reporting when your definitions of v-for directives or scope attributes match your ignorePattern Regular expression. default null, will ignore nothing

Suggestion

  • When your ignorePattern set to ^_, we could provide a suggestion which add a prefix_ to your variable and no more eslint error

The content on this page is adapted from the ESLint User Guide. Copyright © OpenJS Foundation and other contributors, www.openjsf.org. All rights reserved. https://eslint.org/docs/rules/