Skip to content

Commit

Permalink
Fix: no-multiple-empty-lines fails when empty line at EOF (fixes #4214)
Browse files Browse the repository at this point in the history
  • Loading branch information
alberto committed Oct 20, 2015
1 parent ffc9b18 commit 5ca4594
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/rules/no-multiple-empty-lines.js
Expand Up @@ -55,7 +55,7 @@ module.exports = function(context) {
// a single empty line at the end is a valid case regardless of the value of "max" option
if (trimmedLines[trimmedLines.length - 2] !== "" &&
trimmedLines[trimmedLines.length - 1] === "") {
return;
trimmedLines = trimmedLines.slice(0, -1);
}

// Aggregate and count blank lines
Expand Down
5 changes: 5 additions & 0 deletions tests/lib/rules/no-multiple-empty-lines.js
Expand Up @@ -86,6 +86,11 @@ ruleTester.run("no-multiple-empty-lines", rule, {
errors: [ expectedError ],
options: ruleArgs
},
{
code: "// invalid 3\nvar a=5;\n\n\n\nvar b = 3;\n",
errors: [ expectedError ],
options: ruleArgs
},
{
code: "// invalid 4\nvar a = 5;\n\n\n\nb = 3;\nvar c = 5;\n\n\n\nvar d = 3;",
errors: 2,
Expand Down

0 comments on commit 5ca4594

Please sign in to comment.