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" reports only the last function parameter

See original GitHub issue

With the following code:

const func = (req, res, next) => {};

only next is reported with the rule no-unused-vars.

This would not be an big issue but this actually triggers another bigger issue.

With the following code:

const func = (req, res, _next) => {};

and the following configuration:

"no-unused-vars": [ 2, { "argsIgnorePattern": "^_" }]

nothing is reported at all ! Which is IMO more serious.

Issue Analytics

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

github_iconTop GitHub Comments

1reaction
nzakascommented, Sep 13, 2016

Logistics: Use both “bug” and “enhancement” labels if it’s a confirmed bug and the fix would result in more warnings being reported.

1reaction
kaicataldocommented, Sep 13, 2016

@platinumazure Thanks for clarifying - that makes sense! I agree that an enhancement/bug fix for this would be great:

In the second example, ignoring a parameter isn’t the same as using it (or at least shouldn’t be), so I wouldn’t want req and res to be passed over in that case either.

I’m 👍 for @mysticatea’s suggestion to alter the "after-used" option to warn about the last parameter that isn’t ignored (rather than simply the last parameter).

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 disable warn about some unused params, but keep ...
I want to disable no unused params warning in some cases but keep "unused vars" rule. For example here I would want to...
Read more >
Michael Jackson on Twitter: "TypeScript experts: is there a ...
In this case, the `err` parameter is "unused", but I still need it ... which only complains if unused args are found *after*...
Read more >
Disallow unused variables and arguments ( no-unused-vars ...
This rule only works on files that TypeScript deems is a module ... When true, this option will ignore unused function arguments if...
Read more >
explicit-function-return-type | typescript-eslint
* An array of function/method names that will not have their arguments or return values checked. */ allowedNames?: string[] ...
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