mirror of
https://github.com/DavidAnson/markdownlint.git
synced 2025-09-22 05:40:48 +02:00
Add MD006, MD009, MD010 with tests.
This commit is contained in:
parent
e366ee071c
commit
812f5bdfff
3 changed files with 70 additions and 3 deletions
56
lib/rules.js
56
lib/rules.js
|
@ -125,6 +125,30 @@ module.exports = [
|
|||
}
|
||||
},
|
||||
|
||||
{
|
||||
"name": "MD006",
|
||||
"desc": "Consider starting bulleted lists at the beginning of the line",
|
||||
"func": function MD006(params, errors) {
|
||||
var inList = 0;
|
||||
params.tokens.filter(function filterToken(token) {
|
||||
switch (token.type) {
|
||||
case "bullet_list_open":
|
||||
inList++;
|
||||
return inList === 1;
|
||||
case "bullet_list_close":
|
||||
inList--;
|
||||
return false;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}).forEach(function forToken(token) {
|
||||
if (indentFrom(token) !== 0) {
|
||||
errors.push(token.lineNumber);
|
||||
}
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
{
|
||||
"name": "MD007",
|
||||
"desc": "Unordered list indentation",
|
||||
|
@ -144,6 +168,32 @@ module.exports = [
|
|||
}
|
||||
},
|
||||
|
||||
// MD008 does not exist
|
||||
|
||||
{
|
||||
"name": "MD009",
|
||||
"desc": "Trailing spaces",
|
||||
"func": function MD009(params, errors) {
|
||||
params.lines.forEach(function forLine(line, lineIndex) {
|
||||
if (line.match(/\s$/)) {
|
||||
errors.push(lineIndex + 1);
|
||||
}
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
{
|
||||
"name": "MD010",
|
||||
"desc": "Hard tabs",
|
||||
"func": function MD010(params, errors) {
|
||||
params.lines.forEach(function forLine(line, lineIndex) {
|
||||
if (line.match(/\t/)) {
|
||||
errors.push(lineIndex + 1);
|
||||
}
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
{
|
||||
"name": "MD031",
|
||||
"desc": "Fenced code blocks should be surrounded by blank lines",
|
||||
|
@ -173,13 +223,13 @@ module.exports = [
|
|||
var inList = false;
|
||||
var inCode = false;
|
||||
var prevLine = "";
|
||||
params.lines.forEach(function forLine(line, lineNumber) {
|
||||
params.lines.forEach(function forLine(line, lineIndex) {
|
||||
if (!inCode) {
|
||||
var listMarker = line.trim().match(/^([\*\+\-]|(\d+\.))\s/);
|
||||
if (listMarker && !inList && !prevLine.match(/^($|\s)/)) {
|
||||
errors.push(lineNumber + 1);
|
||||
errors.push(lineIndex + 1);
|
||||
} else if (!listMarker && inList && !line.match(/^($|\s)/)) {
|
||||
errors.push(lineNumber);
|
||||
errors.push(lineIndex);
|
||||
}
|
||||
inList = listMarker;
|
||||
}
|
||||
|
|
14
test/bulleted_list_not_at_beginning_of_line.md
Normal file
14
test/bulleted_list_not_at_beginning_of_line.md
Normal file
|
@ -0,0 +1,14 @@
|
|||
Some text
|
||||
|
||||
* Item {MD006}
|
||||
* Item
|
||||
* Item
|
||||
* Item
|
||||
* Item
|
||||
* Item
|
||||
* Item
|
||||
|
||||
Some more text
|
||||
|
||||
* Item {MD006}
|
||||
* Item
|
3
test/whitespace issues.md
Normal file
3
test/whitespace issues.md
Normal file
|
@ -0,0 +1,3 @@
|
|||
Some text {MD009}
|
||||
Some more text {MD010}
|
||||
Some more text
|
Loading…
Add table
Add a link
Reference in a new issue