2018-01-21 21:44:25 -08:00
|
|
|
// @ts-check
|
|
|
|
|
|
|
|
"use strict";
|
|
|
|
|
2019-04-13 11:18:57 -07:00
|
|
|
const { addErrorDetailIf, forEachLine } = require("../helpers");
|
2019-04-10 21:26:59 -07:00
|
|
|
const { lineMetadata } = require("./cache");
|
2018-01-21 21:44:25 -08:00
|
|
|
|
|
|
|
module.exports = {
|
|
|
|
"names": [ "MD012", "no-multiple-blanks" ],
|
|
|
|
"description": "Multiple consecutive blank lines",
|
|
|
|
"tags": [ "whitespace", "blank_lines" ],
|
|
|
|
"function": function MD012(params, onError) {
|
2018-04-27 22:05:34 -07:00
|
|
|
const maximum = params.config.maximum || 1;
|
|
|
|
let count = 0;
|
2019-04-10 21:26:59 -07:00
|
|
|
forEachLine(lineMetadata(), (line, lineIndex, inCode) => {
|
2018-01-21 21:44:25 -08:00
|
|
|
count = (inCode || line.trim().length) ? 0 : count + 1;
|
|
|
|
if (maximum < count) {
|
2019-04-10 21:26:59 -07:00
|
|
|
addErrorDetailIf(onError, lineIndex + 1, maximum, count);
|
2018-01-21 21:44:25 -08:00
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
};
|