Add support for authoring custom rules.

This commit is contained in:
David Anson 2018-02-25 16:04:13 -08:00
parent f24f98e146
commit 802c81f929
6 changed files with 375 additions and 97 deletions

View file

@ -0,0 +1,22 @@
// @ts-check
"use strict";
module.exports = {
"names": [ "any-blockquote" ],
"description": "Rule that reports an error for any blockquote",
"tags": [ "test" ],
"function": function rule(params, onError) {
params.tokens.filter(function filterToken(token) {
return token.type === "blockquote_open";
}).forEach(function forToken(blockquote) {
var lines = blockquote.map[1] - blockquote.map[0];
onError({
"lineNumber": blockquote.lineNumber,
"detail": "Blockquote spans " + lines + " line(s).",
"context": blockquote.line.substr(0, 7),
"range": null
});
});
}
};