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.

Setting values in arguments still flags `unused var`.

See original GitHub issue

Tell us about your environment ESLint Version: 3.17.1
Node Version: 6.2.2
npm Version: 3.9.5

What parser (default, Babel-ESLint, etc.) are you using? babel-eslint 6.1.2

Configuration:

module.exports = {
  root: true,
  parser: 'babel-eslint',
  parserOptions: {
    sourceType: 'module'
  },
  // https://github.com/feross/standard/blob/master/RULES.md#javascript-standard-style
  extends: 'vue',
  // required to lint *.vue files
  plugins: [
    'vue',
    'html'
  ],
  env: {
    browser: true
  },
  // add your custom rules here
  'rules': {
    // allow paren-less arrow functions
    'arrow-parens': 0,
    // allow async-await
    'generator-star-spacing': 0,
    // allow debugger during development
    'no-debugger': process.env.NODE_ENV === 'production' ? 2 : 0,
    'no-return-assign': 2,
    // disallow indentation using both tabs and spaces
    'no-mixed-spaces-and-tabs': 2,
    // ensure consistent 2 space indentation and indent cases under switch
    'indent': [2, 2, {'SwitchCase': 1}]
  }
}

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

I get no-unused-vars for assignments in function arguments:

let bar
this.foo(bar = false)

Issue Analytics

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

github_iconTop GitHub Comments

2reactions
not-an-aardvarkcommented, Mar 15, 2017

Yes, it’s still considered unused, because the value of bar is never read. So the code can be replaced with:

this.foo(false)
0reactions
albertocommented, Mar 22, 2017

Closing this issue as it looks like the question has been answered. Please feel free to visit us in the ESLint Gitter if you have any other issues!

Read more comments on GitHub >

github_iconTop Results From Across the Web

How do I best silence a warning about unused variables?
Unused parameter warnings can simply be suppressed by passing -Wno-unused-parameter to the compiler, but note that this disabling flag must come after any ......
Read more >
no-unused-vars and unused parameters #1939 - eslint/eslint
You'd create a new rule, find the variables you're interested in, then called markVariableAsUsed() on it. We'll add some documentation around it ...
Read more >
Which style to use for unused return parameters in a Python ...
Here's a general rule: If only 1 of the returned values is used, why not simply return that 1 value ...
Read more >
Warning Options (Using the GNU Compiler Collection (GCC))
Where the unused arguments lie between used arguments that are specified with ' $ ' operand number specifications, normally warnings are still given, ......
Read more >
Rules - ESLint - Pluggable JavaScript Linter
The "extends": "eslint:recommended" property in a configuration file ... Disallow the use of undeclared variables unless mentioned in `/*global */` comments.
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