mirror of
https://github.com/DavidAnson/markdownlint.git
synced 2025-09-22 05:40:48 +02:00
Remove state from shared.js, move to cache.js.
This commit is contained in:
parent
827e1acb56
commit
f614f3e1ce
17 changed files with 124 additions and 98 deletions
10
lib/md018.js
10
lib/md018.js
|
@ -2,17 +2,19 @@
|
|||
|
||||
"use strict";
|
||||
|
||||
const shared = require("./shared");
|
||||
const { addErrorContext, atxHeadingSpaceRe, forEachLine,
|
||||
rangeFromRegExp } = require("./shared");
|
||||
const { lineMetadata } = require("./cache");
|
||||
|
||||
module.exports = {
|
||||
"names": [ "MD018", "no-missing-space-atx" ],
|
||||
"description": "No space after hash on atx style heading",
|
||||
"tags": [ "headings", "headers", "atx", "spaces" ],
|
||||
"function": function MD018(params, onError) {
|
||||
shared.forEachLine(function forLine(line, lineIndex, inCode) {
|
||||
forEachLine(lineMetadata(), (line, lineIndex, inCode) => {
|
||||
if (!inCode && /^#+[^#\s]/.test(line) && !/#$/.test(line)) {
|
||||
shared.addErrorContext(onError, lineIndex + 1, line.trim(), null,
|
||||
null, shared.rangeFromRegExp(line, shared.atxHeadingSpaceRe));
|
||||
addErrorContext(onError, lineIndex + 1, line.trim(), null,
|
||||
null, rangeFromRegExp(line, atxHeadingSpaceRe));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue