no-empty-pattern - configure behavior for function parameters
See original GitHub issueWhat rule do you want to change?
no-empty-pattern
Does this change cause the rule to produce more or fewer warnings? fewer if you use it as is. more if following the change I’ll be able to enable it.
How will the change be implemented? (New option, new default behavior, etc.)? new option
Please provide some example code that this change will affect:
Consider a place where an exported/passed method/function must adhere to an arity requirement.
In this case, I use {}
to communicate that I’m not interested in anything from the argument that is null-destructored - and thus, intentionally I create no symbols.
A common example - that the error handler of express requires arity of 4. e.g:
app.use((err, {}, res, {}) => {
logger.error({ err }, 'got error in route');
res.headerSent || res.status(500);
res.end(genericError(err));
});
Now I have to disable one of two rules: no-empty-pattern
, or no-unused-vars
. Which is a pitty.
What does the rule currently do for this code? fails it.
What will the rule do after it’s changed? Provided that I configure it to ignore only the first-level destruction of function arguments - it will pass, while I can still enjoy errors/warnings about all other cases that might indeed be an error.
Are you willing to submit a pull request to implement this change? I’m totally out of capacity now… I suggest you won’t wait for me.
Issue Analytics
- State:
- Created 3 years ago
- Reactions:4
- Comments:6 (3 by maintainers)
Top GitHub Comments
Unfortunately, it looks like there wasn’t enough interest from the team or community to implement this change. While we wish we’d be able to accommodate everyone’s requests, we do need to prioritize. We’ve found that issues failing to reach accepted status after 21 days tend to never be accepted, and as such, we close those issues. This doesn’t mean the idea isn’t interesting or useful, just that it’s not something the team can commit to.
Thanks for contributing to ESLint and we appreciate your understanding.
@anikethsaha - in case like express error-handler - can’t use
(...args)
- because it makes the arity of the function to be zero, where by definition - it has to be 4 to be considered an error handler.Arraity of a function =
func.length
example: