2 * @fileoverview Disallows multiple blank lines.
3 * implementation adapted from the no-trailing-spaces rule.
5 * @copyright 2014 Greg Cochard. All rights reserved.
9 //------------------------------------------------------------------------------
11 //------------------------------------------------------------------------------
13 module.exports = function(context) {
15 // Use options.max or 2 as default
18 if (context.options.length) {
19 numLines = context.options[0].max;
22 //--------------------------------------------------------------------------
24 //--------------------------------------------------------------------------
28 "Program": function checkBlankLines(node) {
29 var lines = context.getSourceLines(),
34 trimmedLines = lines.map(function(str) {
38 // Aggregate and count blank lines
40 lastLocation = currentLocation;
41 currentLocation = trimmedLines.indexOf("", currentLocation + 1);
42 if (lastLocation === currentLocation - 1) {
45 if (blankCounter >= numLines) {
47 line: lastLocation + 1,
48 column: lines[lastLocation].length
50 context.report(node, location, "Multiple blank lines not allowed.");
53 // Finally, reset the blank counter
56 } while (currentLocation !== -1);