mirror of
https://github.com/DavidAnson/markdownlint.git
synced 2025-12-22 08:50:13 +01:00
Move each rule implementation into its own file (fixes #83).
This commit is contained in:
parent
49e36f817c
commit
9ba143555d
42 changed files with 1289 additions and 1028 deletions
41
lib/md004.js
Normal file
41
lib/md004.js
Normal file
|
|
@ -0,0 +1,41 @@
|
|||
// @ts-check
|
||||
|
||||
"use strict";
|
||||
|
||||
var shared = require("./shared");
|
||||
|
||||
module.exports = {
|
||||
"names": [ "MD004", "ul-style" ],
|
||||
"description": "Unordered list style",
|
||||
"tags": [ "bullet", "ul" ],
|
||||
"function": function MD004(params, onError) {
|
||||
var style = params.config.style || "consistent";
|
||||
var expectedStyle = style;
|
||||
var nestingStyles = [];
|
||||
shared.flattenLists(params).forEach(function forList(list) {
|
||||
if (list.unordered) {
|
||||
if (expectedStyle === "consistent") {
|
||||
expectedStyle = shared.unorderedListStyleFor(list.items[0]);
|
||||
}
|
||||
list.items.forEach(function forItem(item) {
|
||||
var itemStyle = shared.unorderedListStyleFor(item);
|
||||
if (style === "sublist") {
|
||||
var nesting = list.nesting;
|
||||
if (!nestingStyles[nesting] &&
|
||||
(itemStyle !== nestingStyles[nesting - 1])) {
|
||||
nestingStyles[nesting] = itemStyle;
|
||||
} else {
|
||||
shared.addErrorDetailIf(onError, item.lineNumber,
|
||||
nestingStyles[nesting], itemStyle, null,
|
||||
shared.rangeFromRegExp(item.line, shared.listItemMarkerRe));
|
||||
}
|
||||
} else {
|
||||
shared.addErrorDetailIf(onError, item.lineNumber,
|
||||
expectedStyle, itemStyle, null,
|
||||
shared.rangeFromRegExp(item.line, shared.listItemMarkerRe));
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
Loading…
Add table
Add a link
Reference in a new issue