1 # enforce a maximum file length (max-lines)
3 Some people consider large files a code smell. Large files tend to do a lot of things and can make it hard following what's going. While there is not an objective maximum number of lines considered acceptable in a file, most people would agree it should not be in the thousands. Recommendations usually range from 100 to 500 lines.
7 This rule enforces a maximum number of lines per file, in order to aid in maintainability and reduce complexity.
9 Please note that most editors show an additional empty line at the end if the file ends with a line break. This rule does not count that extra line.
13 This rule has a number or object option:
15 * `"max"` (default `300`) enforces a maximum number of lines in a file
17 * `"skipBlankLines": true` ignore lines made up purely of whitespace.
19 * `"skipComments": true` ignore lines containing just comments
23 Examples of **incorrect** code for this rule with a max value of `2`:
26 /*eslint max-lines: ["error", 2]*/
33 /*eslint max-lines: ["error", 2]*/
40 /*eslint max-lines: ["error", 2]*/
46 Examples of **correct** code for this rule with a max value of `2`:
49 /*eslint max-lines: ["error", 2]*/
55 /*eslint max-lines: ["error", 2]*/
61 /*eslint max-lines: ["error", 2]*/
68 Examples of **incorrect** code for this rule with the `{ "skipBlankLines": true }` option:
71 /*eslint max-lines: ["error", {"max": 2, "skipBlankLines": true}]*/
78 Examples of **correct** code for this rule with the `{ "skipBlankLines": true }` option:
81 /*eslint max-lines: ["error", {"max": 2, "skipBlankLines": true}]*/
89 Examples of **incorrect** code for this rule with the `{ "skipComments": true }` option:
92 /*eslint max-lines: ["error", {"max": 2, "skipComments": true}]*/
99 Examples of **correct** code for this rule with the `{ "skipComments": true }` option:
102 /*eslint max-lines: ["error", {"max": 2, "skipComments": true}]*/
108 ## When Not To Use It
110 You can turn this rule off if you are not concerned with the number of lines in your files.
114 * [Software Module size and file size](https://web.archive.org/web/20160725154648/http://www.mind2b.com/component/content/article/24-software-module-size-and-file-size)
118 * [complexity](complexity.md)
119 * [max-depth](max-depth.md)
120 * [max-lines-per-function](max-lines-per-function.md)
121 * [max-nested-callbacks](max-nested-callbacks.md)
122 * [max-params](max-params.md)
123 * [max-statements](max-statements.md)
127 * **JSCS**: [maximumNumberOfLines](https://jscs-dev.github.io/rule/maximumNumberOfLines)