src/content/docs/linter/rules/use-max-params.mdx
import { Tabs, TabItem } from '@astrojs/starlight/components';
<Tabs> <TabItem label="JavaScript (and super languages)" icon="seti:javascript"> ## Summary - Rule available since: `v2.2.0` - Diagnostic Category: [`lint/complexity/useMaxParams`](/reference/diagnostics#diagnostic-category) - This rule isn't recommended, so you need to enable it. - This rule doesn't have a fix. - The default severity of this rule is [**warning**](/reference/diagnostics#warning). - Sources: - Same as [`max-params`](https://eslint.org/docs/latest/rules/max-params) - Same as [`too_many_arguments`](https://rust-lang.github.io/rust-clippy/master/#too_many_arguments) - Same as [`@typescript-eslint/max-params`](https://typescript-eslint.io/rules/max-params){
"linter": {
"rules": {
"complexity": {
"useMaxParams": "error"
}
}
}
}
Enforce a maximum number of parameters in function definitions.
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.
function foo(a, b, c, d, e, f, g, h) {
// too many parameters
}
const bar = (a, b, c, d, e, f, g, h) => {
// too many parameters
}
class Baz {
method(a, b, c, d, e, f, g, h) {
// too many parameters
}
}
function foo(a, b, c) {
// within limit
}
const bar = (a, b, c) => {
// within limit
}
class Baz {
method(a, b, c) {
// within limit
}
}
The maximum number of parameters allowed (default: 4).