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
16
lib/md004.js
16
lib/md004.js
|
|
@ -2,7 +2,9 @@
|
|||
|
||||
"use strict";
|
||||
|
||||
const shared = require("./shared");
|
||||
const { addErrorDetailIf, listItemMarkerRe,
|
||||
rangeFromRegExp } = require("./shared");
|
||||
const { flattenedLists } = require("./cache");
|
||||
|
||||
// Returns the unordered list style for a list item token
|
||||
function unorderedListStyleFor(token) {
|
||||
|
|
@ -25,12 +27,12 @@ module.exports = {
|
|||
const style = params.config.style || "consistent";
|
||||
let expectedStyle = style;
|
||||
const nestingStyles = [];
|
||||
shared.flattenLists().forEach(function forList(list) {
|
||||
flattenedLists().forEach((list) => {
|
||||
if (list.unordered) {
|
||||
if (expectedStyle === "consistent") {
|
||||
expectedStyle = unorderedListStyleFor(list.items[0]);
|
||||
}
|
||||
list.items.forEach(function forItem(item) {
|
||||
list.items.forEach((item) => {
|
||||
const itemStyle = unorderedListStyleFor(item);
|
||||
if (style === "sublist") {
|
||||
const nesting = list.nesting;
|
||||
|
|
@ -38,14 +40,14 @@ module.exports = {
|
|||
(itemStyle !== nestingStyles[nesting - 1])) {
|
||||
nestingStyles[nesting] = itemStyle;
|
||||
} else {
|
||||
shared.addErrorDetailIf(onError, item.lineNumber,
|
||||
addErrorDetailIf(onError, item.lineNumber,
|
||||
nestingStyles[nesting], itemStyle, null, null,
|
||||
shared.rangeFromRegExp(item.line, shared.listItemMarkerRe));
|
||||
rangeFromRegExp(item.line, listItemMarkerRe));
|
||||
}
|
||||
} else {
|
||||
shared.addErrorDetailIf(onError, item.lineNumber,
|
||||
addErrorDetailIf(onError, item.lineNumber,
|
||||
expectedStyle, itemStyle, null, null,
|
||||
shared.rangeFromRegExp(item.line, shared.listItemMarkerRe));
|
||||
rangeFromRegExp(item.line, listItemMarkerRe));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue