Add MD032 with tests, improve infrastructure.

This commit is contained in:
David Anson 2015-02-24 23:35:34 -08:00
parent 160146ac3a
commit aef1524308
3 changed files with 111 additions and 1 deletions

View file

@ -3,6 +3,14 @@
var fs = require("fs");
var rules = require("./rules");
function numberComparison(a, b) {
return a - b;
}
function uniqueFilterForSorted(value, index, array) {
return (index === 0) || (value > array[index - 1]);
}
function lintFile(file, options, callback) {
fs.readFile(file, { "encoding": "utf8" }, function readFile(err, contents) {
if (err) {
@ -14,7 +22,8 @@ function lintFile(file, options, callback) {
var rule = rules[name];
var errors = rule(lines);
if (errors.length) {
result[name] = errors;
errors.sort(numberComparison);
result[name] = errors.filter(uniqueFilterForSorted);
}
});
callback(null, result);