Add MD014 with tests.

This commit is contained in:
David Anson 2015-03-05 23:30:01 -08:00
parent 434c7f388c
commit 62314e61b1
4 changed files with 55 additions and 3 deletions

View file

@ -18,7 +18,7 @@ function lintFile(file, config, callback) {
callback(err);
} else {
var tokens = md.parse(contents, {});
var lines = contents.split(/\r\n|\r|\n/g);
var lines = contents.split(/\r\n|\r|\n/);
tokens.forEach(function forToken(token) {
if (token.lines) {
token.line = lines[token.lines[0]];

View file

@ -216,7 +216,7 @@ module.exports = [
var exclusions = [];
filterTokens(params.tokens, "code_block", "fence")
.forEach(function forToken(token) {
for (var i = token.lines[0] ; i < token.lines[1] ; i++) {
for (var i = token.lines[0]; i < token.lines[1]; i++) {
exclusions.push(i);
}
});
@ -246,6 +246,25 @@ module.exports = [
}
},
{
"name": "MD014",
"desc": "Dollar signs used before commands without showing output",
"func": function MD014(params, errors) {
filterTokens(params.tokens, "code_block", "fence")
.forEach(function forToken(token) {
if (token.content && token.content
.split(/\r\n|\r|\n/)
.filter(function filterLine(line) {
return line;
}).every(function forLine(line) {
return /^\$\s/.test(line);
})) {
errors.push(token.lines[0] + 1);
}
});
}
},
{
"name": "MD028",
"desc": "Blank line inside blockquote",