eslint/max-params Style ​
What it does ​
Enforce a maximum number of parameters in function definitions which by default is three.
Why is this bad? ​
Functions that take numerous parameters can be difficult to read and write because it requires the memorization of what each parameter is, its type, and the order they should appear in. As a result, many coders adhere to a convention that caps the number of parameters a function can take.
Examples ​
Examples of incorrect code for this rule:
function foo(bar, baz, qux, qxx) {
doSomething();
}
let foo = (bar, baz, qux, qxx) => {
doSomething();
};
Examples of correct code for this rule:
function foo(bar, baz, qux) {
doSomething();
}
let foo = (bar, baz, qux) => {
doSomething();
};
Options ​
max ​
{ "max": number }
This option is for changing the maximum allowed number of function parameters.
For example { "max": 4 }
would mean that having a function take four parameters is allowed which overrides the default of three.
How to use ​
To enable this rule in the CLI or using the config file, you can use:
oxlint --deny max-params
{
"rules": {
"max-params": "error"
}
}