mirror of
https://github.com/DavidAnson/markdownlint.git
synced 2025-12-16 14:00:13 +01:00
Allow a custom rule's onError implementation to override that rule's information URL for each error.
This commit is contained in:
parent
14974e52a9
commit
c699b8e22b
7 changed files with 235 additions and 18 deletions
4
lib/markdownlint.d.ts
vendored
4
lib/markdownlint.d.ts
vendored
|
|
@ -218,6 +218,10 @@ type RuleOnErrorInfo = {
|
|||
* Context for the error.
|
||||
*/
|
||||
context?: string;
|
||||
/**
|
||||
* Link to more information.
|
||||
*/
|
||||
information?: URL;
|
||||
/**
|
||||
* Column number (1-based) and length.
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -59,7 +59,7 @@ function validateRuleList(ruleList, synchronous) {
|
|||
if (
|
||||
!result &&
|
||||
rule.information &&
|
||||
(Object.getPrototypeOf(rule.information) !== URL.prototype)
|
||||
!helpers.isUrl(rule.information)
|
||||
) {
|
||||
result = newError("information");
|
||||
}
|
||||
|
|
@ -629,6 +629,10 @@ function lintContent(
|
|||
!helpers.isString(errorInfo.context)) {
|
||||
throwError("context");
|
||||
}
|
||||
if (errorInfo.information &&
|
||||
!helpers.isUrl(errorInfo.information)) {
|
||||
throwError("information");
|
||||
}
|
||||
if (errorInfo.range &&
|
||||
(!Array.isArray(errorInfo.range) ||
|
||||
(errorInfo.range.length !== 2) ||
|
||||
|
|
@ -681,12 +685,13 @@ function lintContent(
|
|||
cleanFixInfo.insertText = fixInfo.insertText;
|
||||
}
|
||||
}
|
||||
const information = errorInfo.information || rule.information;
|
||||
results.push({
|
||||
lineNumber,
|
||||
"ruleName": rule.names[0],
|
||||
"ruleNames": rule.names,
|
||||
"ruleDescription": rule.description,
|
||||
"ruleInformation": rule.information ? rule.information.href : null,
|
||||
"ruleInformation": information ? information.href : null,
|
||||
"errorDetail": errorInfo.detail || null,
|
||||
"errorContext": errorInfo.context || null,
|
||||
"errorRange": errorInfo.range ? [ ...errorInfo.range ] : null,
|
||||
|
|
@ -1314,6 +1319,7 @@ module.exports = markdownlint;
|
|||
* @property {number} lineNumber Line number (1-based).
|
||||
* @property {string} [detail] Detail about the error.
|
||||
* @property {string} [context] Context for the error.
|
||||
* @property {URL} [information] Link to more information.
|
||||
* @property {number[]} [range] Column number (1-based) and length.
|
||||
* @property {RuleOnErrorFixInfo} [fixInfo] Fix information.
|
||||
*/
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue