mirror of
https://github.com/DavidAnson/markdownlint.git
synced 2025-12-16 22:10:13 +01:00
Update MD018/MD019/MD020/MD021 to report fixInfo for violations.
This commit is contained in:
parent
c8a74bd72c
commit
316bfeadaa
8 changed files with 167 additions and 50 deletions
20
lib/md018.js
20
lib/md018.js
|
|
@ -2,8 +2,7 @@
|
|||
|
||||
"use strict";
|
||||
|
||||
const { addErrorContext, atxHeadingSpaceRe, forEachLine,
|
||||
rangeFromRegExp } = require("../helpers");
|
||||
const { addErrorContext, forEachLine } = require("../helpers");
|
||||
const { lineMetadata } = require("./cache");
|
||||
|
||||
module.exports = {
|
||||
|
|
@ -12,9 +11,20 @@ module.exports = {
|
|||
"tags": [ "headings", "headers", "atx", "spaces" ],
|
||||
"function": function MD018(params, onError) {
|
||||
forEachLine(lineMetadata(), (line, lineIndex, inCode) => {
|
||||
if (!inCode && /^#+[^#\s]/.test(line) && !/#$/.test(line)) {
|
||||
addErrorContext(onError, lineIndex + 1, line.trim(), null,
|
||||
null, rangeFromRegExp(line, atxHeadingSpaceRe));
|
||||
if (!inCode && /^#+[^#\s]/.test(line) && !/#\s*$/.test(line)) {
|
||||
const hashCount = /^#+/.exec(line)[0].length;
|
||||
addErrorContext(
|
||||
onError,
|
||||
lineIndex + 1,
|
||||
line.trim(),
|
||||
null,
|
||||
null,
|
||||
[ 1, hashCount + 1 ],
|
||||
{
|
||||
"editColumn": hashCount + 1,
|
||||
"insertText": " "
|
||||
}
|
||||
);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue