Update MD027/MD044 to report fixInfo for violations.

This commit is contained in:
David Anson 2019-09-09 22:03:59 -07:00
parent 316bfeadaa
commit 00a7e765ec
3 changed files with 59 additions and 26 deletions

View file

@ -29,9 +29,30 @@ module.exports = {
.replace(/^\W*/, "").replace(/\W*$/, "");
if (!names.includes(wordMatch)) {
const lineNumber = token.lineNumber + index + fenceOffset;
const range = [ match.index + 1, wordMatch.length ];
addErrorDetailIf(onError, lineNumber,
name, match[1], null, null, range);
const fullLine = params.lines[lineNumber - 1];
let matchIndex = match.index;
const matchLength = wordMatch.length;
const fullLineWord =
fullLine.slice(matchIndex, matchIndex + matchLength);
if (fullLineWord !== wordMatch) {
// Attempt to fix bad offset due to inline content
matchIndex = fullLine.indexOf(wordMatch);
}
const range = [ matchIndex + 1, matchLength ];
addErrorDetailIf(
onError,
lineNumber,
name,
match[1],
null,
null,
range,
{
"editColumn": matchIndex + 1,
"deleteCount": matchLength,
"insertText": name
}
);
}
}
}