]> git.proxmox.com Git - pve-eslint.git/blob - eslint/docs/rules/max-params.md
050d2a348502a49b9db8064fba1f6785e804143e
[pve-eslint.git] / eslint / docs / rules / max-params.md
1 # enforce a maximum number of parameters in function definitions (max-params)
2
3 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.
4
5 ```js
6 function foo (bar, baz, qux, qxx) { // four parameters, may be too many
7 doSomething();
8 }
9 ```
10
11 ## Rule Details
12
13 This rule enforces a maximum number of parameters allowed in function definitions.
14
15 ## Options
16
17 This rule has a number or object option:
18
19 * `"max"` (default `3`) enforces a maximum number of parameters in function definitions
20
21 **Deprecated:** The object property `maximum` is deprecated; please use the object property `max` instead.
22
23 ### max
24
25 Examples of **incorrect** code for this rule with the default `{ "max": 3 }` option:
26
27 ```js
28 /*eslint max-params: ["error", 3]*/
29 /*eslint-env es6*/
30
31 function foo (bar, baz, qux, qxx) {
32 doSomething();
33 }
34
35 let foo = (bar, baz, qux, qxx) => {
36 doSomething();
37 };
38 ```
39
40 Examples of **correct** code for this rule with the default `{ "max": 3 }` option:
41
42 ```js
43 /*eslint max-params: ["error", 3]*/
44 /*eslint-env es6*/
45
46 function foo (bar, baz, qux) {
47 doSomething();
48 }
49
50 let foo = (bar, baz, qux) => {
51 doSomething();
52 };
53 ```
54
55 ## Related Rules
56
57 * [complexity](complexity.md)
58 * [max-depth](max-depth.md)
59 * [max-len](max-len.md)
60 * [max-lines](max-lines.md)
61 * [max-lines-per-function](max-lines-per-function.md)
62 * [max-nested-callbacks](max-nested-callbacks.md)
63 * [max-statements](max-statements.md)