mirror of
https://github.com/DavidAnson/markdownlint.git
synced 2025-09-22 05:40:48 +02:00
Add MD041 with tests.
This commit is contained in:
parent
eabe2387bc
commit
7f5dd9ab6b
17 changed files with 113 additions and 18 deletions
23
lib/rules.js
23
lib/rules.js
|
@ -779,5 +779,28 @@ module.exports = [
|
|||
}
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
{
|
||||
"name": "MD041",
|
||||
"desc": "First line in file should be a top level header",
|
||||
"tags": [ "headers" ],
|
||||
"func": function MD041(params, errors) {
|
||||
var firstHeader = null;
|
||||
params.tokens.every(function forToken(token) {
|
||||
if (token.type === "heading_open") {
|
||||
firstHeader = token;
|
||||
return false;
|
||||
} else if (token.lineNumber > 1) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
});
|
||||
if (!firstHeader ||
|
||||
(firstHeader.lineNumber !== 1) ||
|
||||
(firstHeader.tag !== "h1")) {
|
||||
errors.push(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
];
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue