mirror of
https://github.com/DavidAnson/markdownlint.git
synced 2025-12-17 06:20:12 +01:00
Add MD032 with tests, improve infrastructure.
This commit is contained in:
parent
160146ac3a
commit
aef1524308
3 changed files with 111 additions and 1 deletions
|
|
@ -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);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue