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 // Attempt to fix bad offset due to inline content
matchIndex = fullLine.indexOf(wordMatch); 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( addErrorDetailIf(
onError, onError,
lineNumber, lineNumber,
@ -49,11 +56,7 @@ module.exports = {
null, null,
null, null,
range, range,
{ fixInfo
"editColumn": matchIndex + 1,
"deleteCount": matchLength,
"insertText": name
}
); );
} }
} }

View file

@ -69,3 +69,15 @@ Bare URL exempt https://github.com/DavidAnson/MARKDOWNLINT {MD034}
A short paragraph A short paragraph
about node.js and {MD044} about node.js and {MD044}
javascript. {MD044} javascript. {MD044}
{MD044} `javascript`
{MD044} `code
javascript`
{MD044} `code
javascript
code`
{MD044} `javascript
code`