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.

Extend rule: max-params

See original GitHub issue

What rule do you want to change? max-params

Does this change cause the rule to produce more or fewer warnings? fewer

How will the change be implemented? (New option, new default behavior, etc.)? I would hope to see a new option ignore-callbacks

Please provide some example code that this change will affect:

// max-params, warn, 1

function foo(bar, baz) { ... }

function foo({ bar, baz }) { ... }

getData((error, result) => { ... });

What does the rule currently do for this code? First function gets a warning because it has more than 1 argument. Second function is ok as it only has one argument. Callback gets a warning as it has 2 arguments.

What will the rule do after it’s changed? First function gets a warning. Second function is ok Callback is ok

I usually have max-params set to warn with 1 as I like to force the use of “named” params via objects.

It would be nice to have an option (ignore-callbacks?) for max-params to ignore functions that are used as callbacks. I’m not in control of the signature of expected callback functions and I keep getting a lot of warnings for these functions.

Issue Analytics

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

github_iconTop GitHub Comments

1reaction
platinumazurecommented, Nov 2, 2017

Hi @zimme, thanks for the issue!

Would you mind editing your original post to conform to our rule change proposal template? It makes evaluation of proposed rule changes so much easier for us 😄

Personally, I could see us adding an exceptions string array or regex which would not report functions with certain names. Or, I could also see some sort of option representing number and/or names of parameters which could also be used to avoid reporting certain cases… Do think on it a bit and see if you can come up with a few possibilities when you fill in the rule change proposal template 😄

0reactions
ilyavolodincommented, Dec 24, 2017

Great! If you end up creating a custom rule for this, can you post a link here, so that other might learn about it. Closing this issue, as it seems resolved.

Read more comments on GitHub >

github_iconTop Results From Across the Web

max-params - 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 >
C++ Expand only part of the parameter pack - Stack Overflow
First, I store all minimum and maximum parameters values into two containers. Then I define a deriveLimit template function wich gets as ...
Read more >
David Dal Busco on Twitter: "Is there an eslint rule that enforces the ...
Is there an eslint rule that enforces the usage of interfaces and "destructuring function args" as ... max-params - ESLint - Pluggable JavaScript...
Read more >
JSHint Options Reference
If you would like to enforce rules relating to code style, check out the JSCS project. This option lets you set the maximum...
Read more >
List of available rules - ESLint - Pluggable JavaScript linter
The "extends": "eslint:recommended" property in a configuration file enables ... These rules relate to possible syntax or logic errors in JavaScript code: ...
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