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

@ -306,6 +306,8 @@ Tags: whitespace, blank_lines
Aliases: no-multiple-blanks
Parameters: maximum (number; default 1)
This rule is triggered when there are multiple consecutive blank lines in the
document:
@ -323,6 +325,9 @@ To fix this, delete the offending lines:
Note: this rule will not be triggered if there are multiple consecutive blank
lines inside code blocks.
Note: The `maximum` parameter can be used to configure the maximum number of
consecutive blank lines.
## MD013 - Line length
Tags: line_length

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;
});
}
},

View file

@ -857,7 +857,7 @@ module.exports.readme = function readme(test) {
};
module.exports.doc = function doc(test) {
test.expect(294);
test.expect(295);
fs.readFile("doc/Rules.md", shared.utf8Encoding,
function readFile(err, contents) {
test.ifError(err);

View file

@ -0,0 +1,6 @@
{
"default": true,
"MD012": {
"maximum": 3
}
}

View file

@ -0,0 +1,46 @@
# Heading
Text
Text
Text
Text
Text {MD012:16}
Text {MD012:21} {MD012:22}
Text {MD012:27} {MD012:28} {MD012:29}
Text
Text {MD012:36}
Text
Text
Text

View file

@ -0,0 +1,24 @@
# Heading
Text
Text
Text {MD012:7}
Text {MD012:10} {MD012:11}
Text {MD012:14} {MD012:15} {MD012:16}
Text
Text {MD012:21}
Text