forked from DavidAnson/markdownlint
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmd002.js
More file actions
22 lines (19 loc) · 640 Bytes
/
md002.js
File metadata and controls
22 lines (19 loc) · 640 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
// @ts-check
"use strict";
const { addErrorDetailIf } = require("../helpers");
module.exports = {
"names": [ "MD002", "first-heading-h1", "first-header-h1" ],
"description": "First heading should be a top-level heading",
"tags": [ "headings", "headers" ],
"function": function MD002(params, onError) {
const level = Number(params.config.level || 1);
const tag = "h" + level;
params.parsers.markdownit.tokens.every(function forToken(token) {
if (token.type === "heading_open") {
addErrorDetailIf(onError, token.lineNumber, tag, token.tag);
return false;
}
return true;
});
}
};