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.

option to exclude functions from no-unused-vars

See original GitHub issue

I want to keep the no-unused-vars rule as an error, but in an ES2015 module, functions that are not called are considered “unused variables” and trigger the error. I would like to be able to treat functions distinctly (and it would even make most intuitive sense to me for unused rules for variables and named functions to be separate, but I’m aware that’s a gray area).

Issue Analytics

  • State:closed
  • Created 8 years ago
  • Comments:9 (5 by maintainers)

github_iconTop GitHub Comments

12reactions
nzakascommented, Jan 28, 2016

@chrylis your best option is to disable the rule until you want the warning. Put /*eslint-disable no-unused-vars*/ at the top of your file until you want the warnings again.

0reactions
nzakascommented, Feb 1, 2016

@jmlopez-rod if it’s really per-function, then you need to manually disable it using inline comments. If you just want arguments to not count, then you can configure that: http://eslint.org/docs/rules/no-unused-vars.html#options

@chrylis I’m sorry, there’s just no good way to distinguish between variables that are functions and variables that are not (given the multiple ways that functions can be defined). I’m afraid introducing such an option would lead to more confusion that it would solve. For now, you can manually disable the rule when you want.

Read more comments on GitHub >

github_iconTop Results From Across the Web

no-unused-vars - ESLint - Pluggable JavaScript Linter
The ignoreRestSiblings option is a boolean (default: false ). Using a Rest Property it is possible to “omit” properties from an object, but...
Read more >
Vue: disable no-unused-vars error: the simplest fix
You are using eslint, which add rules to your code, no unused vars is one of them, which means you aren't allowed to...
Read more >
The 3 Best ESLint No-Unused-Vars Option Settings (Make it ...
ESLint no-unused-vars ignoreRestSiblings. Removing unused vars helps you comply with the max-lines-per-function rule.
Read more >
no-unused-variable - Rule
Rule: no-unused-variable. Disallows unused imports, variables, functions and private class members. Similar to tsc's –noUnusedParameters and –noUnusedLocals ...
Read more >
Rule no-unused-vars
This rule is aimed at eliminating unused variables, functions and variables in parameters of functions, as such, warns when one is found.
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