2018-01-21 21:44:25 -08:00
|
|
|
// @ts-check
|
|
|
|
|
|
|
|
"use strict";
|
|
|
|
|
2019-04-10 21:26:59 -07:00
|
|
|
const { addErrorDetailIf, listItemMarkerRe, rangeFromRegExp } =
|
2019-04-13 11:18:57 -07:00
|
|
|
require("../helpers");
|
2019-04-10 21:26:59 -07:00
|
|
|
const { flattenedLists } = require("./cache");
|
2018-01-21 21:44:25 -08:00
|
|
|
|
|
|
|
module.exports = {
|
|
|
|
"names": [ "MD006", "ul-start-left" ],
|
|
|
|
"description":
|
|
|
|
"Consider starting bulleted lists at the beginning of the line",
|
|
|
|
"tags": [ "bullet", "ul", "indentation" ],
|
|
|
|
"function": function MD006(params, onError) {
|
2019-04-10 21:26:59 -07:00
|
|
|
flattenedLists().forEach((list) => {
|
2019-09-02 15:35:43 -07:00
|
|
|
if (list.unordered && !list.nesting && (list.indent !== 0)) {
|
2019-11-29 21:45:59 -08:00
|
|
|
list.items.forEach((item) => {
|
|
|
|
const { lineNumber, line } = item;
|
|
|
|
addErrorDetailIf(
|
|
|
|
onError,
|
|
|
|
lineNumber,
|
|
|
|
0,
|
|
|
|
list.indent,
|
|
|
|
null,
|
|
|
|
null,
|
|
|
|
rangeFromRegExp(line, listItemMarkerRe),
|
|
|
|
{
|
2021-02-06 19:55:22 -08:00
|
|
|
"deleteCount": line.length - line.trimStart().length
|
2019-11-29 21:45:59 -08:00
|
|
|
});
|
|
|
|
});
|
2018-01-21 21:44:25 -08:00
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
};
|