Add MD044 proper-names "Proper names should have the correct capitalization" (fixes #39).

This commit is contained in:
David Anson 2016-12-22 13:34:18 -08:00
parent 46cbcfa55e
commit d8975282dc
13 changed files with 185 additions and 5 deletions

View file

@ -1090,5 +1090,27 @@ module.exports = [
}
}
}
},
{
"name": "MD044",
"desc": "Proper names should have the correct capitalization",
"tags": [ "spelling" ],
"aliases": [ "proper-names" ],
"regexp": null,
"func": function MD044(params, errors) {
var names = params.options.names || [];
names.forEach(function forName(name) {
var escapedName = escapeForRegExp(name);
var namePattern = "\\b" + escapedName + "\\b";
var anyNameRe = new RegExp(namePattern, "gi");
forEachLine(params, function forLine(line, lineIndex) {
var matches = line.match(anyNameRe) || [];
matches.forEach(function forMatch(match) {
errors.addDetailIf(lineIndex + 1, name, match);
});
});
});
}
}
];