Add markdownlint "version" property to custom rule "params" object in case it is ever necessary for a rule to specialize its behavior.

This commit is contained in:
David Anson 2024-09-29 18:11:41 -07:00
parent ee50519e00
commit d3819c4e75
6 changed files with 39 additions and 5 deletions

View file

@ -1338,6 +1338,30 @@ test("customRulesOnErrorInvalidHandledSync", (t) => {
t.deepEqual(actualResult, expectedResult, "Undetected issues.");
});
test("customRulesVersion", (t) => new Promise((resolve) => {
t.plan(2);
// eslint-disable-next-line jsdoc/valid-types
/** @type import("../lib/markdownlint").Options */
const options = {
"customRules": [
{
"names": [ "name" ],
"description": "description",
"tags": [ "tag" ],
"parser": "none",
"function": function stringName(params) {
t.is(params.version, version, "Incorrect version");
}
}
],
"files": "doc/CustomRules.md"
};
markdownlint(options, function callback(err) {
t.falsy(err);
resolve();
});
}));
test("customRulesFileName", (t) => new Promise((resolve) => {
t.plan(2);
// eslint-disable-next-line jsdoc/valid-types