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.

separate args from no-unused-vars and introduce no-unused-args

See original GitHub issue

ESLint Version: v3.2.2

The rule no-unused-vars includes the option for unused args in functions. Declaring unused variables is (in my configuration) declared as an error. There isn’t a reason to have an unused variable. On the other hand, unused arguments are sometimes necessary for clarity and therefore I like them to be listed as warnings. For example,

// Here I like to leave `res` and `next` because I like all http handlers to be declared this way
function getHandler(req, res, next) {
}

My first thought was to include the ability to give different levels for args and vars in the no-unused-vars rule, but then I immediately thought that maybe the two should be declared separately.

Issue Analytics

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

github_iconTop GitHub Comments

1reaction
vitorbalcommented, Aug 12, 2016

Thanks for reaching out, @blockloop! There are already a few args-related options that you could use to achieve this. For instance, you could use the argsIgnorePattern option to whitelist “res” and “next”, or you could use the pattern from the example so anything starting with an underscore would be ignored:

no-unused-vars: ["error", { "argsIgnorePattern": "^_" }]
0reactions
albertocommented, Aug 26, 2016

Closing as this seems out of scope.

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 >
[no-unused-vars] False positives on required args in interface ...
I believe that no-unused-vars should not error out when a function is an implementation of a defined interface. There are valid use cases...
Read more >
ESLint - Configuring "no-unused-vars" for TypeScript
I think the use of "plugin:@typescript-eslint/eslint-recommended" introduces bunch of unwanted rules. One is probably better off using ...
Read more >
vue/no-unused-vars
This rule report variable definitions of v-for directives or scope attributes if those are not used. 1.
Read more >
Fullstack part9 | First steps with TypeScript - Full stack open
The calculator should accept three arguments: two numbers and the operation, either multiply, add or divide, which tells it what to do with...
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