Add MD029 with tests.

This commit is contained in:
David Anson 2015-03-07 22:46:45 -08:00
parent 35067149c9
commit 5591cf4587
5 changed files with 58 additions and 1 deletions

View file

@ -333,6 +333,30 @@ module.exports = [
}
},
{
"name": "MD029",
"desc": "Ordered list item prefix",
"func": function MD029(params, errors) {
var style = params.options.style || "one";
var number = 0;
params.tokens.forEach(function forToken(token) {
if (token.type === "ordered_list_open") {
number = 1;
} else if (token.type === "ordered_list_close") {
number = 0;
} else if ((token.type === "list_item_open") && number) {
var regex = new RegExp("^\\s*" + String(number) + "\\. ");
if (!regex.test(token.line)) {
errors.push(token.lineNumber);
}
if (style === "ordered") {
number++;
}
}
});
}
},
{
"name": "MD031",
"desc": "Fenced code blocks should be surrounded by blank lines",

View file

@ -1,4 +1,5 @@
{
"default": true,
"MD004": false
"MD004": false,
"MD029": false
}

View file

@ -0,0 +1,13 @@
Good list:
1. Do this.
1. Do that.
1. ???
1. Profit!
Bad list:
1. Do this.
2. Do nothing. {MD029}
3. ??? {MD029}
4. Failed! {MD029}

View file

@ -0,0 +1,6 @@
{
"default": true,
"MD029": {
"style": "ordered"
}
}

View file

@ -0,0 +1,13 @@
Good list:
1. Do this.
2. Do that.
3. ???
4. Profit!
Bad list:
1. Do this.
1. Do nothing. {MD029}
1. ??? {MD029}
1. Failed! {MD029}