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

@ -3,8 +3,8 @@
"use strict";
module.exports = {
"names": [ "blockquote" ],
"description": "Rule that reports an error for blockquotes",
"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) {

18
test/rules/first-line.js Normal file
View file

@ -0,0 +1,18 @@
// @ts-check
"use strict";
module.exports = {
"names": [ "first-line" ],
"description": "Rule that reports an error for the first line",
"tags": [ "test" ],
"function": function rule(params, onError) {
// Unconditionally report an error for line 1
onError({
"lineNumber": 1,
"detail": null,
"context": null,
"range": null
});
}
};

View file

@ -2,17 +2,21 @@
"use strict";
var blockquote = require("./blockquote");
module.exports.blockquote = blockquote;
var anyBlockquote = require("./any-blockquote");
module.exports.anyBlockquote = anyBlockquote;
var everyNLines = require("./every-n-lines");
module.exports.everyNLines = everyNLines;
var firstLine = require("./first-line");
module.exports.firstLine = firstLine;
var lettersEX = require("./letters-E-X");
module.exports.lettersEX = lettersEX;
module.exports.all = [
blockquote,
anyBlockquote,
everyNLines,
firstLine,
lettersEX
];