Extend rule: max-params
See original GitHub issueWhat 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:
- Created 6 years ago
- Comments:8 (4 by maintainers)
Top GitHub Comments
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 😄
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.