Update MD022/MD031/MD032 to report fixInfo for violations, normalize input to fixErrors.

This commit is contained in:
David Anson 2019-08-28 21:47:07 -07:00
parent 2cd27c58f2
commit a062e7c6bd
6 changed files with 357 additions and 38 deletions

View file

@ -22,16 +22,33 @@ module.exports = {
const [ topIndex, nextIndex ] = token.map;
for (let i = 0; i < linesAbove; i++) {
if (!isBlankLine(lines[topIndex - i - 1])) {
addErrorDetailIf(onError, topIndex + 1, linesAbove, i, "Above",
lines[topIndex].trim());
return;
addErrorDetailIf(
onError,
topIndex + 1,
linesAbove,
i,
"Above",
lines[topIndex].trim(),
null,
{
"insertText": "\n"
});
}
}
for (let i = 0; i < linesBelow; i++) {
if (!isBlankLine(lines[nextIndex + i])) {
addErrorDetailIf(onError, topIndex + 1, linesBelow, i, "Below",
lines[topIndex].trim());
return;
addErrorDetailIf(
onError,
topIndex + 1,
linesBelow,
i,
"Below",
lines[topIndex].trim(),
null,
{
"lineNumber": nextIndex + 1,
"insertText": "\n"
});
}
}
});