-
Notifications
You must be signed in to change notification settings - Fork 538
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Default error handler, next(), and ESLint's no unused var rule #78
Comments
Yes, the biggest issue is that Express error middleware is generally not compatible with that rule. You can probably add some kind of ESLint comment to disable that rule just for the error handling function. The reason it's there, but unused, is because in Express, an error middlware is differentiated from a normal middleware by the function taking 4 arguments rather than 3 arguments (i.e. You are also getting an error when you manually call It boils down to that rule not being compatible with Express error middlewares is all. I have never user ESLint (only JSHint), so I don't know how to tell you what you need to change in your ESLint rules. |
It looks like here is the issue on ESLint: eslint/eslint#1494 seems they say just don't use that rule. |
Thanks so much, @dougwilson. I have relaxed it to a warning for now. |
Since 2015 the rule You can use http://eslint.org/docs/rules/no-unused-vars#argsignorepattern Example in
|
Is it possible to use This is nearest answer I have found. |
@zckrs it is a little bit unsafe, custom error handler appears once in your code, so you may prefer using |
Add option to set nested-link color
You can also use: // eslint-disable-next-line no-unused-vars To be extra specific |
It's a [known issue][1] with Express middleware and ESLint. [1]: expressjs/generator#78 (comment)
None of the above-mentioned solutions are working for something like:
Had to use:
Weird thing is, I am not getting error for unused |
My Function
You can use:
Result is zero warnings on lint This pattern is shown in https://eslint.org/docs/rules/no-unused-vars |
This may be an Express-specific issue, but I'm trying to wrap my head around it.
Given the below code, ESLint complains that
next
is never used.My questions:
next()
implicitly called in Node middleware? I thought the best practice was to not call it explicitly in middleware./foo
as a test route.Calling
next()
by itselfconsole
browser
Calling
next(err)
browser
console
Forgive my newbness
The text was updated successfully, but these errors were encountered: