Closed andreineculau closed 5 years ago
There's a slew of reasons for the params rule. To quote our documentation:
Note: This rule mode resembles the built-in "no-unused-vars" rule, but instead focuses only on the parameters of => arrow functions.
So first, this plugin applies rules only to arrow functions, whereas those rules you cited are focused on all functions. I do not necessarily feel that all function types should have the same rules, so that's the reason why this plugin has these rules, focused only on arrow functions.
That's an important distinction. The philosophy of this plugin is to apply rules specifically and only to arrow functions, under the assumption that they might need different rules than other functions. ESLint core has a number of rules which apply more broadly, but there are "gaps" where you cannot apply some of the behaviors from this plugin to normal functions, even if you might like to. But that's not this plugin's concern. Someone could make another plugin that could apply the same kinds of rules to non-arrow functions.
The built-in "no-unused-vars" rule applies to all variables; there doesn't appear to be a way to restrict it to only deal with function parameters. This is undesirable in that it's too broad. I prefer the narrow scope of rule checking of params. Moreover, I want to apply the rules only to my arrow functions, not all my functions.
All rules in this plugin support the trivial config, which disables checking on certain kinds of "trivial" arrow functions, which are often so simple that it's inappropriate to apply the same rules to as you do to more substantial arrow functions. None of the built-in eslint rules let you exempt trivial arrow functions.
All of the checks/modes in params can also exempt from consideration parameters by name, using the allowed
config. This is more powerful than the built-in eslint behavior, which has the argsIgnorePattern
, but only for the "no-unused-vars" rule; it's not possible to define that kind of exemption for the "max-params" rule.
alright, I follow your reasoning. Thanks for nice explanation.
afaik eslint's max-params and no-unused-vars handle
AsyncFunctionExpression