Add maximum parameter to MD012/no-multiple-blanks (fixes #27).

This commit is contained in:
David Anson 2016-10-03 21:42:44 -07:00
parent ce9ec8fb5e
commit affd94e061
6 changed files with 86 additions and 5 deletions

View file

@ -358,13 +358,13 @@ module.exports = [
"tags": [ "whitespace", "blank_lines" ],
"aliases": [ "no-multiple-blanks" ],
"func": function MD012(params, errors) {
var prevLine = "-";
var maximum = params.options.maximum || 1;
var count = 0;
forEachLine(params, function forLine(line, lineIndex, inCode) {
line = line.trim();
if (!inCode && !line.length && !prevLine.length) {
count = (inCode || line.trim().length) ? 0 : count + 1;
if (maximum < count) {
errors.push(lineIndex + 1);
}
prevLine = line;
});
}
},