Update MD044/proper-names to avoid providing bogus range when proper name could not be found.

This commit is contained in:
David Anson 2020-05-13 20:59:18 -07:00
parent f635d7b72c
commit 87aac66d68
2 changed files with 21 additions and 6 deletions

View file

@ -40,7 +40,14 @@ module.exports = {
// Attempt to fix bad offset due to inline content
matchIndex = fullLine.indexOf(wordMatch);
}
const range = [ matchIndex + 1, matchLength ];
const range = (matchIndex === -1) ?
null :
[ matchIndex + 1, matchLength ];
const fixInfo = (matchIndex === -1) ? null : {
"editColumn": matchIndex + 1,
"deleteCount": matchLength,
"insertText": name
};
addErrorDetailIf(
onError,
lineNumber,
@ -49,11 +56,7 @@ module.exports = {
null,
null,
range,
{
"editColumn": matchIndex + 1,
"deleteCount": matchLength,
"insertText": name
}
fixInfo
);
}
}