-
-
Notifications
You must be signed in to change notification settings - Fork 681
[Fixes #294] Fix no-unused-vars rule #302
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
As it happens, there is a discussion that core I like that approach. for (let i = node.variables.length - 1; i >= 0 && node.varibles[i].references.length === 0; --i) {
// report it.
} |
I think this PR introduces exactly that @mysticatea, it works as follows: <template>
<div v-for="(v, i, c) in foo">{{v}}</div>
</template> ☝️ reports: <template>
<div v-for="(v, i, c) in foo">{{i}}</div>
</template> ☝️ reports: <template>
<div v-for="(v, i, c) in foo">{{c}}</div>
</template> ☝️ reports nothing |
tests/lib/rules/no-unused-vars.js
Outdated
}, | ||
{ | ||
code: '<template><div v-for="(v, i, c) in foo">{{i}}</div></template>', | ||
errors: ["'v' is defined but never used.", "'c' is defined but never used."] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You are wrong in the 2nd case.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Holly molly! You're absolutely right. Thank you for being so vigilant! I'll update it tomorrow :)
Should be good now @mysticatea |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thank you!
This PR fixes
no-unused-vars
rule, so it doesn't throw a warning, when some of the properties are not used even when the last property was used.As pointed in #294 currently code like this throws warnings:
In this PR I'm checking if the last property was referenced anywhere. If yes then we simply ignore other properties, if not -> we check references of all properties as before.