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.

[no-unused-vars] is not reported in a scenario.

See original GitHub issue

I am using eslint@2.8.0 babel-eslint@6.0.4 node v6.0.0 npm 3.8.6

My rule is set to "no-unused-vars": 1

function test(options) {
    options = options || {};
    // Shouldn't this should give no-unused-vars error here?
}

test({});

In above scenario since options object is not used thus IMHO this should raise no-unused-vars error.

I tested this on online demo of eslint also.

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:16 (12 by maintainers)

github_iconTop GitHub Comments

6reactions
platinumazurecommented, Jun 9, 2016

Hmm… I’ve reconsidered. I think it might be sufficient to provide an option which simply says, if a variable is on LHS and RHS of an assignment, don’t assume it is used.

function myFunc(a) {
    a = a + 1;
    // But wait, I'm still not really using a beyond the assignment,
    // so the assignment was actually pretty useless.
}

Also, I’m wondering about the compound-assignment operators. Do they count as usage?

function myOtherFunc(a) {
    a += 1;  // Is this a "use" per no-unused-params?
}

If the compound-assignment doesn’t count as a use, I fail to see how unwrapped assign-after-operator (a = a + 1) should count as a use either.

1reaction
mikesherovcommented, Jun 21, 2016

👍 for @platinumazure’s suggestion, not optional. That is, until a is used for something other than self assignment, consider it unused.

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 >
How to fix "eslint(no-unused-vars)" in vue script - Stack Overflow
Use string template to build your url correctly like below; axios.delete(`${server.baseURL}/blog/delete?postID=${id}`).then(data => {.
Read more >
no-unused-vars - TypeScript ESLint
This rule extends the base eslint/no-unused-vars rule. ... Note: you must disable the base rule as it can report incorrect errors "no-unused-vars": "off",...
Read more >
vue/no-unused-vars
Rule Details #. This rule report variable definitions of v-for directives or scope attributes if those are not used.
Read more >
Understanding ESLint Rules - Mastering JS
Every ESLint rule has a name: this rule is called no-unused-vars . ... Suppose you have the below one-line script test.js in the...
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