mirror of
https://github.com/DavidAnson/markdownlint.git
synced 2025-12-17 06:20:12 +01: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
12
lib/md030.js
12
lib/md030.js
|
|
@ -2,7 +2,9 @@
|
|||
|
||||
"use strict";
|
||||
|
||||
const shared = require("./shared");
|
||||
const { addErrorDetailIf, listItemMarkerRe, rangeFromRegExp } =
|
||||
require("./shared");
|
||||
const { flattenedLists } = require("./cache");
|
||||
|
||||
module.exports = {
|
||||
"names": [ "MD030", "list-marker-space" ],
|
||||
|
|
@ -13,17 +15,17 @@ module.exports = {
|
|||
const olSingle = params.config.ol_single || 1;
|
||||
const ulMulti = params.config.ul_multi || 1;
|
||||
const olMulti = params.config.ol_multi || 1;
|
||||
shared.flattenLists().forEach(function forList(list) {
|
||||
flattenedLists().forEach((list) => {
|
||||
const lineCount = list.lastLineIndex - list.open.map[0];
|
||||
const allSingle = lineCount === list.items.length;
|
||||
const expectedSpaces = list.unordered ?
|
||||
(allSingle ? ulSingle : ulMulti) :
|
||||
(allSingle ? olSingle : olMulti);
|
||||
list.items.forEach(function forItem(item) {
|
||||
list.items.forEach((item) => {
|
||||
const match = /^[\s>]*\S+(\s+)/.exec(item.line);
|
||||
shared.addErrorDetailIf(onError, item.lineNumber,
|
||||
addErrorDetailIf(onError, item.lineNumber,
|
||||
expectedSpaces, (match ? match[1].length : 0), null, null,
|
||||
shared.rangeFromRegExp(item.line, shared.listItemMarkerRe));
|
||||
rangeFromRegExp(item.line, listItemMarkerRe));
|
||||
});
|
||||
});
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue