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 bug (for plus plus)

See original GitHub issue

config is "no-unused-vars": "warn" warn:

var j = 0; // j is assigned a value but never used
while(typeof window === 'object'){
  j++;
}

ok:

var j = 0;
while(typeof window === 'object'){
  j = j + 1;
}

can you make the j++ to ok ?

Issue Analytics

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

github_iconTop GitHub Comments

1reaction
platinumazurecommented, Nov 14, 2016

Look, the problem is that except for the increment, no one else sees the value of j at all. You could remove j entirely from your code and it would have the same effects to calling code.

Your code, in terms of observable side effects, is exactly the same as this code:

while(typeof window === 'object'){
}

You need to finish writing your code (as in, write the lines where j is actually passed to another function or returned or used in an expression). Right now, the rule is correctly noting that j is not used except for self-modification.

0reactions
not-an-aardvarkcommented, Aug 14, 2017

Closing because this is working as intended.

Read more comments on GitHub >

github_iconTop Results From Across the Web

'Form' is defined but never used no-unused-vars
I keep on getting the error Form' is defined but never used no-unused-vars and it says: Search for the keywords to learn more...
Read more >
no-unnecessary-condition - TypeScript ESLint
This rule requires type information to run. Any expression being used as a condition must be able to evaluate as truthy or falsy...
Read more >
Fix most of the remaining no-unused-vars issues for local ...
This is the next step for bug 1312407. This fixes most of the no-unused-vars for local scope in browser/. There's only a handful...
Read more >
disallow the unary operators ++ and -- (no-plusplus) - ESLint
Because the unary ++ and -- operators are subject to automatic semicolon insertion, differences in whitespace can change semantics of source code. var...
Read more >
User Guide | eslint-plugin-vue
Above, plus rules to considerably improve code readability and/or dev ... Other rules - because they're not covering potential bugs 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