mirror of
https://github.com/DavidAnson/markdownlint.git
synced 2025-12-26 18:48:48 +01:00
Move each rule implementation into its own file (fixes #83).
This commit is contained in:
parent
49e36f817c
commit
9ba143555d
42 changed files with 1289 additions and 1028 deletions
22
lib/md001.js
Normal file
22
lib/md001.js
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
// @ts-check
|
||||
|
||||
"use strict";
|
||||
|
||||
var shared = require("./shared");
|
||||
|
||||
module.exports = {
|
||||
"names": [ "MD001", "header-increment" ],
|
||||
"description": "Header levels should only increment by one level at a time",
|
||||
"tags": [ "headers" ],
|
||||
"function": function MD001(params, onError) {
|
||||
var prevLevel = 0;
|
||||
shared.filterTokens(params, "heading_open", function forToken(token) {
|
||||
var level = parseInt(token.tag.slice(1), 10);
|
||||
if (prevLevel && (level > prevLevel)) {
|
||||
shared.addErrorDetailIf(onError, token.lineNumber,
|
||||
"h" + (prevLevel + 1), "h" + level);
|
||||
}
|
||||
prevLevel = level;
|
||||
});
|
||||
}
|
||||
};
|
||||
Loading…
Add table
Add a link
Reference in a new issue