mirror of
https://github.com/DavidAnson/markdownlint.git
synced 2025-12-17 06:20:12 +01:00
Change export of rules to include description.
This commit is contained in:
parent
aef1524308
commit
5d35b8dfea
2 changed files with 51 additions and 44 deletions
|
|
@ -18,12 +18,11 @@ function lintFile(file, options, callback) {
|
|||
} else {
|
||||
var lines = contents.split(/\r\n|\n/g);
|
||||
var result = {};
|
||||
Object.keys(rules).forEach(function forRule(name) {
|
||||
var rule = rules[name];
|
||||
var errors = rule(lines);
|
||||
rules.forEach(function forRule(rule) {
|
||||
var errors = rule.func(lines);
|
||||
if (errors.length) {
|
||||
errors.sort(numberComparison);
|
||||
result[name] = errors.filter(uniqueFilterForSorted);
|
||||
result[rule.name] = errors.filter(uniqueFilterForSorted);
|
||||
}
|
||||
});
|
||||
callback(null, result);
|
||||
|
|
|
|||
16
lib/rules.js
16
lib/rules.js
|
|
@ -9,8 +9,11 @@ function padAndTrim(lines) {
|
|||
"");
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
"MD031": function MD031(lines) {
|
||||
module.exports = [
|
||||
{
|
||||
"name": "MD031",
|
||||
"desc": "Fenced code blocks should be surrounded by blank lines",
|
||||
"func": function MD031(lines) {
|
||||
// Some parsers have trouble detecting fenced code blocks without
|
||||
// surrounding whitespace, so examine the lines directly.
|
||||
lines = padAndTrim(lines);
|
||||
|
|
@ -26,9 +29,13 @@ module.exports = {
|
|||
}
|
||||
});
|
||||
return errors;
|
||||
}
|
||||
},
|
||||
|
||||
"MD032": function MD032(lines) {
|
||||
{
|
||||
"name": "MD032",
|
||||
"desc": "Lists should be surrounded by blank lines",
|
||||
"func": function MD032(lines) {
|
||||
// Some parsers have trouble detecting lists without surrounding
|
||||
// whitespace, so examine the lines directly.
|
||||
var errors = [];
|
||||
|
|
@ -53,4 +60,5 @@ module.exports = {
|
|||
});
|
||||
return errors;
|
||||
}
|
||||
};
|
||||
}
|
||||
];
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue