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 ### ignoreTopLevelFunctions
117 Examples of additional **correct** code for this rule with the `{ "max": 10 }, { "ignoreTopLevelFunctions": true }` options:
120 /*eslint max-statements: ["error", 10, { "ignoreTopLevelFunctions": true }]*/
139 * [complexity](complexity.md)
140 * [max-depth](max-depth.md)
141 * [max-len](max-len.md)
142 * [max-lines](max-lines.md)
143 * [max-lines-per-function](max-lines-per-function.md)
144 * [max-nested-callbacks](max-nested-callbacks.md)
145 * [max-params](max-params.md)