mirror of
https://github.com/DavidAnson/markdownlint.git
synced 2026-01-04 06:58:49 +01:00
Add support for using custom rules.
This commit is contained in:
parent
4619a8c824
commit
f24f98e146
11 changed files with 497 additions and 71 deletions
23
test/rules/every-n-lines.js
Normal file
23
test/rules/every-n-lines.js
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
// @ts-check
|
||||
|
||||
"use strict";
|
||||
|
||||
module.exports = {
|
||||
"names": [ "every-n-lines" ],
|
||||
"description": "Rule that reports an error every N lines",
|
||||
"tags": [ "test" ],
|
||||
"function": function rule(params, onError) {
|
||||
var n = params.config.n || 2;
|
||||
params.lines.forEach(function forLine(line, lineIndex) {
|
||||
var lineNumber = lineIndex + 1;
|
||||
if ((lineNumber % n) === 0) {
|
||||
onError({
|
||||
"lineNumber": lineNumber,
|
||||
"detail": "Line number " + lineNumber,
|
||||
"context": null,
|
||||
"range": null
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
Loading…
Add table
Add a link
Reference in a new issue