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-empty-pattern - configure behavior for function parameters

See original GitHub issue

What 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:closed
  • Created 3 years ago
  • Reactions:4
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
eslint-deprecated[bot]commented, Jun 25, 2020

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.

1reaction
oshercommented, May 24, 2020

@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:

const mw = (req, res, next) => {}
assert.equal(f.length , 3)

const errmw = (err, req, res, next) => {}
assert.equal(f.length , 4)

const variage = (...args) => {}
assert.equal(vairage.length, 0)

Read more comments on GitHub >

github_iconTop Results From Across the Web

Setting up behaviors: parameters - sortie-nd
Setting up behaviors: parameters. Almost all behaviors need values and settings from the user to function. These are called the behavior parameters.
Read more >
behaviour of function parameters in c programming
You use two different ways to pass parameters. The first implementation of the mutate function uses call by value where a copy of...
Read more >
no-param-reassign - 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 >
about Functions Advanced Parameters - PowerShell
Explains how to add parameters to advanced functions.
Read more >
MOOS-IvP : Helm - Helm Behaviors browse
7.2.1 A Summary of the Full Set of General Behavior Parameters ... The setParam() function: parameter-value pairs are handled to configure a behavior's...
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