1 # enforce a maximum number of statements allowed in function blocks (max-statements)
3 The `max-statements` rule allows you to specify the maximum number of statements allowed in a function.
7 var bar = 1; // one statement
8 var baz = 2; // two statements
9 var qux = 3; // three statements
15 This rule enforces a maximum number of statements allowed in function blocks.
19 This rule has a number or object option:
21 * `"max"` (default `10`) enforces a maximum number of statements allows in function blocks
23 **Deprecated:** The object property `maximum` is deprecated; please use the object property `max` instead.
25 This rule has an object option:
27 * `"ignoreTopLevelFunctions": true` ignores top-level functions
31 Examples of **incorrect** code for this rule with the default `{ "max": 10 }` option:
34 /*eslint max-statements: ["error", 10]*/
49 var foo11 = 11; // Too many.
64 var foo11 = 11; // Too many.
68 Examples of **correct** code for this rule with the default `{ "max": 10 }` option:
71 /*eslint max-statements: ["error", 10]*/
87 // The number of statements in the inner function does not count toward the
107 // The number of statements in the inner function does not count toward the
108 // statement maximum.
115 Note that this rule does not apply to class static blocks, and that statements in class static blocks do not count as statements in the enclosing function.
117 Examples of **correct** code for this rule with `{ "max": 2 }` option:
120 /*eslint max-statements: ["error", 2]*/
139 ### ignoreTopLevelFunctions
141 Examples of additional **correct** code for this rule with the `{ "max": 10 }, { "ignoreTopLevelFunctions": true }` options:
144 /*eslint max-statements: ["error", 10, { "ignoreTopLevelFunctions": true }]*/
163 * [complexity](complexity.md)
164 * [max-depth](max-depth.md)
165 * [max-len](max-len.md)
166 * [max-lines](max-lines.md)
167 * [max-lines-per-function](max-lines-per-function.md)
168 * [max-nested-callbacks](max-nested-callbacks.md)
169 * [max-params](max-params.md)