Add typings for Rule object to all Rule samples and examples.

This commit is contained in:
David Anson 2024-03-06 21:18:51 -08:00
parent cdc30b1279
commit c287e49eac
11 changed files with 34 additions and 9 deletions

View file

@ -4,6 +4,10 @@
const { filterTokens } = require("markdownlint-rule-helpers");
/** @typedef {import("../../lib/markdownlint").MarkdownItToken} MarkdownItToken */
/** @typedef {(MarkdownItToken) => void} FilterTokensCallback */
/** @type import("../../lib/markdownlint").Rule */
module.exports = {
"names": [ "any-blockquote" ],
"description": "Rule that reports an error for any blockquote",
@ -13,13 +17,18 @@ module.exports = {
),
"tags": [ "test" ],
"function": (params, onError) => {
filterTokens(params, "blockquote_open", (blockquote) => {
const lines = blockquote.map[1] - blockquote.map[0];
onError({
"lineNumber": blockquote.lineNumber,
"detail": "Blockquote spans " + lines + " line(s).",
"context": blockquote.line.substr(0, 7)
});
});
filterTokens(
params,
"blockquote_open",
/** @type FilterTokensCallback */
(blockquote) => {
const lines = blockquote.map[1] - blockquote.map[0];
onError({
"lineNumber": blockquote.lineNumber,
"detail": "Blockquote spans " + lines + " line(s).",
"context": blockquote.line.substr(0, 7)
});
}
);
}
};