Add optional "information" property to custom rules to provide a link to more information.

This commit is contained in:
David Anson 2019-01-15 21:56:38 -08:00
parent b77dd5ccd3
commit ff86e1d7f1
14 changed files with 201 additions and 6 deletions

View file

@ -4,6 +4,7 @@
const fs = require("fs");
const path = require("path");
const { URL } = require("url");
const md = require("markdown-it")({ "html": true });
const rules = require("./rules");
const shared = require("./shared");
@ -41,6 +42,11 @@ function validateRuleList(ruleList) {
result = newError(property);
}
});
if (!result && rule.information) {
if (Object.getPrototypeOf(rule.information) !== URL.prototype) {
result = newError("information");
}
}
if (!result) {
rule.names.forEach(function forName(name) {
const nameUpper = name.toUpperCase();
@ -373,6 +379,8 @@ function lintContent(
errorObject.ruleNames = rule.names;
}
errorObject.ruleDescription = rule.description;
errorObject.ruleInformation =
rule.information ? rule.information.href : null;
errorObject.errorDetail = error.detail;
errorObject.errorContext = error.context;
errorObject.errorRange = error.range;