question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

vue/no-unused-vars needs configuration options similar to eslint/no-unused-vars

See original GitHub issue

Tell us about your environment

  • ESLint Version: v4.13.1
  • eslint-plugin-vue Version: eslint-plugin-vue@^4.0.0-beta.2
  • Node Version: v8.4.0

Please show your full configuration:

{
    "env": {
        "browser": true
    },
    "extends": [
        "eslint:recommended",
        "plugin:vue/recommended"
    ],
    "parserOptions": {
        "sourceType": "module"
    },
    "rules": {
        "indent": [
            "error",
            4,
            {
                "SwitchCase": 1
            }
        ],
        "linebreak-style": [
            "error",
            "windows"
        ],
        "quotes": [
            "error",
            "double",
            {
                "avoidEscape": true,
                "allowTemplateLiterals": true
            }
        ],
        "semi": [
            "error",
            "always"
        ],
        "no-console": [
            "off"
        ],
        "no-unused-vars": [
            "error",
            {
                "args": "after-used",
                "argsIgnorePattern": "^_"
            }
        ],
        "vue/html-self-closing": "off",
        "vue/html-indent": [
            "error", 
            4
        ],
        "vue/max-attributes-per-line": "off",
        "vue/order-in-components": "off"
    }
}

What did you do? Please include the actual source code causing the issue.

<template>
<div id="app">
      <div v-for="(thing, key, index) in things" :key="thing.id" :class="{ 'every-other': index % 2 === 0 }">
        {{ thing.id }} - {{ index }}
      </div>
</div>
</template>
<style>
.every-other {
  background-color: red;
}

div {
  width: 100px;
}
</style>
<script>
new Vue({
  el: '#app',
  data: () => ({
    things:  {
      thing1: { id: "thing 1" },
      thing2: { id: "thing 2" },
      thing3: { id: "thing 3" },
      thing4: { id: "thing 4" },
      thing5: { id: "thing 5" },
      thing6: { id: "thing 6" }
    }
  })
})
</script>

What did you expect to happen? v-for supports optional 2nd and 3rd params, and it’s not unexpected that the 2nd param would be unused. eslint/no-unused-vars allows for configurations that take this into account, such as in my config:

        "no-unused-vars": [
            "error",
            {
                "args": "after-used",
                "argsIgnorePattern": "^_"
            }
        ],

What actually happened? Please include the actual, raw output from ESLint. The ‘key’ variable is unused and therefore causes an error. [eslint-plugin-vue] [vue/no-unused-vars] ‘key’ is defined but never used.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:3
  • Comments:8 (3 by maintainers)

github_iconTop GitHub Comments

9reactions
sangdthcommented, Feb 5, 2019

When I work with Element UI, they have template with scope that I never use, but Element will not work without it. So I need options to put at least, scope variable name into exception.

<template slot="header" slot-scope="scope">
    Custom header, never touches the scope.
</template>
2reactions
ota-meshicommented, Mar 13, 2020
Read more comments on GitHub >

github_iconTop Results From Across the Web

no-unused-vars - ESLint - Pluggable JavaScript Linter
A pluggable and configurable linter tool for identifying and reporting on patterns in JavaScript. Maintain your code quality with ease.
Read more >
ESLint - Configuring "no-unused-vars" for TypeScript
VS Code, using eslint, was giving me warnings about unused variables in my type declarations for function callbacks. These options, added to my ......
Read more >
The 3 Best ESLint No-Unused-Vars Option Settings (Make it ...
1 No-Unused-Vars ignoreRestSiblings: Allow Unused Values When Using the Rest Property · 2 No-Unused-Vars destructuredArrayIgnorePattern: Allow ...
Read more >
no-unused-vars - TypeScript ESLint
Disallow unused variables. ... This rule extends the base eslint/no-unused-vars rule. It adds support for TypeScript features, such as types.
Read more >
vue/no-unused-vars
disallow unused variable definitions of v-for directives or scope ... which add a prefix _ to your variable and no more eslint error ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found