mirror of
https://github.com/DavidAnson/markdownlint.git
synced 2025-12-17 22:40:13 +01:00
Validate errorInfo.fixInfo object/properties in extension calls to onError.
This commit is contained in:
parent
5895ea62cb
commit
65f6d38978
3 changed files with 95 additions and 22 deletions
|
|
@ -382,6 +382,37 @@ function lintContent(
|
|||
lines[errorInfo.lineNumber - 1].length))) {
|
||||
throwError("range");
|
||||
}
|
||||
const fixInfo = errorInfo.fixInfo;
|
||||
if (fixInfo) {
|
||||
if (!helpers.isObject(fixInfo)) {
|
||||
throwError("fixInfo");
|
||||
}
|
||||
if ((fixInfo.lineNumber !== undefined) &&
|
||||
(!helpers.isNumber(fixInfo.lineNumber) ||
|
||||
(fixInfo.lineNumber < 1) ||
|
||||
(fixInfo.lineNumber > lines.length))) {
|
||||
throwError("fixInfo.lineNumber");
|
||||
}
|
||||
const effectiveLineNumber = fixInfo.lineNumber || errorInfo.lineNumber;
|
||||
if ((fixInfo.editColumn !== undefined) &&
|
||||
(!helpers.isNumber(fixInfo.editColumn) ||
|
||||
(fixInfo.editColumn < 1) ||
|
||||
(fixInfo.editColumn >
|
||||
lines[effectiveLineNumber - 1].length + 1))) {
|
||||
throwError("fixInfo.editColumn");
|
||||
}
|
||||
if ((fixInfo.deleteCount !== undefined) &&
|
||||
(!helpers.isNumber(fixInfo.deleteCount) ||
|
||||
(fixInfo.deleteCount < -1) ||
|
||||
(fixInfo.deleteCount >
|
||||
lines[effectiveLineNumber - 1].length))) {
|
||||
throwError("fixInfo.deleteCount");
|
||||
}
|
||||
if ((fixInfo.insertText !== undefined) &&
|
||||
!helpers.isString(fixInfo.insertText)) {
|
||||
throwError("fixInfo.insertText");
|
||||
}
|
||||
}
|
||||
errors.push({
|
||||
"lineNumber": errorInfo.lineNumber + frontMatterLines.length,
|
||||
"detail": errorInfo.detail || null,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue