mirror of
https://github.com/DavidAnson/markdownlint.git
synced 2025-12-20 16:00:13 +01:00
Moved rules into their own files
Everything under `lib/rules/*` is a rules file (with the name of the rule in camelCase), re-exported into an array in `lib/rules.js`. Moved the regular expressions from `lib/rules.js` to `lib/expressions.js`, and the rest of the variables into `lib/shared.js`.
This commit is contained in:
parent
77e27cbe09
commit
b63647f6b1
43 changed files with 1283 additions and 1177 deletions
28
lib/rules/listMarkerSpace.js
Normal file
28
lib/rules/listMarkerSpace.js
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
var shared = require("../shared");
|
||||
var expressions = require("../expressions");
|
||||
|
||||
module.exports = {
|
||||
"name": "MD030",
|
||||
"desc": "Spaces after list markers",
|
||||
"tags": [ "ol", "ul", "whitespace" ],
|
||||
"aliases": [ "list-marker-space" ],
|
||||
"regexp": expressions.listItemMarkerRe,
|
||||
"func": function MD030(params, errors) {
|
||||
var ulSingle = params.options.ul_single || 1;
|
||||
var olSingle = params.options.ol_single || 1;
|
||||
var ulMulti = params.options.ul_multi || 1;
|
||||
var olMulti = params.options.ol_multi || 1;
|
||||
shared.flattenLists(params).forEach(function forList(list) {
|
||||
var lineCount = list.lastLineIndex - list.open.map[0];
|
||||
var allSingle = lineCount === list.items.length;
|
||||
var expectedSpaces = list.unordered ?
|
||||
(allSingle ? ulSingle : ulMulti) :
|
||||
(allSingle ? olSingle : olMulti);
|
||||
list.items.forEach(function forItem(item) {
|
||||
var match = /^[\s>]*\S+(\s+)/.exec(item.line);
|
||||
errors.addDetailIf(item.lineNumber,
|
||||
expectedSpaces, (match ? match[1].length : 0));
|
||||
});
|
||||
});
|
||||
}
|
||||
};
|
||||
Loading…
Add table
Add a link
Reference in a new issue