Include file/string name in params object for custom rules (fixes #119).

This commit is contained in:
David Anson 2018-05-25 17:28:56 -07:00
parent 8c87a20677
commit 1c816897c1
3 changed files with 53 additions and 5 deletions

View file

@ -2282,6 +2282,50 @@ module.exports.customRulesOnErrorLazy = function customRulesOnErrorLazy(test) {
});
};
module.exports.customRulesFileName = function customRulesFileName(test) {
test.expect(2);
const options = {
"customRules": [
{
"names": [ "name" ],
"description": "description",
"tags": [ "tag" ],
"function": function stringName(params) {
test.equal(params.name, "doc/CustomRules.md", "Incorrect file name");
}
}
],
"files": "doc/CustomRules.md"
};
markdownlint(options, function callback(err) {
test.ifError(err);
test.done();
});
};
module.exports.customRulesStringName = function customRulesStringName(test) {
test.expect(2);
const options = {
"customRules": [
{
"names": [ "name" ],
"description": "description",
"tags": [ "tag" ],
"function": function stringName(params) {
test.equal(params.name, "string", "Incorrect string name");
}
}
],
"strings": {
"string": "# Heading"
}
};
markdownlint(options, function callback(err) {
test.ifError(err);
test.done();
});
};
module.exports.customRulesDoc = function customRulesDoc(test) {
test.expect(2);
markdownlint({