vue/no-unused-vars needs configuration options similar to eslint/no-unused-vars
See original GitHub issueTell 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:
- Created 6 years ago
- Reactions:3
- Comments:8 (3 by maintainers)
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
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.Hi.
We plan to add option to
vue/no-unused-vars
rule.https://github.com/vuejs/eslint-plugin-vue/pull/1070/files#diff-771e0befcf053e5a67a7c1c6ca67956e