markdownlint 0.20.0 → 0.20.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CONTRIBUTING.md +47 -47
- package/LICENSE +21 -21
- package/README.md +881 -868
- package/demo/markdownlint-browser.js +5438 -5306
- package/doc/CustomRules.md +313 -313
- package/doc/Rules.md +1847 -1795
- package/helpers/LICENSE +21 -21
- package/helpers/README.md +50 -50
- package/helpers/helpers.js +687 -627
- package/helpers/package.json +18 -18
- package/lib/cache.js +24 -24
- package/lib/markdownlint.d.ts +352 -352
- package/lib/markdownlint.js +1101 -1101
- package/lib/md001.js +22 -22
- package/lib/md002.js +22 -22
- package/lib/md003.js +42 -42
- package/lib/md004.js +43 -43
- package/lib/md005.js +69 -69
- package/lib/md006.js +34 -34
- package/lib/md007.js +47 -47
- package/lib/md009.js +77 -77
- package/lib/md010.js +38 -38
- package/lib/md011.js +38 -38
- package/lib/md012.js +32 -32
- package/lib/md013.js +99 -99
- package/lib/md014.js +53 -53
- package/lib/md018.js +34 -34
- package/lib/md019.js +39 -39
- package/lib/md020.js +62 -62
- package/lib/md021.js +60 -60
- package/lib/md022.js +56 -56
- package/lib/md023.js +38 -38
- package/lib/md024.js +38 -38
- package/lib/md025.js +32 -32
- package/lib/md026.js +40 -40
- package/lib/md027.js +56 -56
- package/lib/md028.js +38 -38
- package/lib/md029.js +66 -66
- package/lib/md030.js +50 -50
- package/lib/md031.js +39 -39
- package/lib/md032.js +50 -50
- package/lib/md033.js +45 -45
- package/lib/md034.js +61 -61
- package/lib/md035.js +21 -21
- package/lib/md036.js +56 -56
- package/lib/md037.js +150 -89
- package/lib/md038.js +68 -68
- package/lib/md039.js +64 -64
- package/lib/md040.js +18 -18
- package/lib/md041.js +31 -31
- package/lib/md042.js +41 -41
- package/lib/md043.js +45 -45
- package/lib/md044.js +77 -71
- package/lib/md045.js +18 -18
- package/lib/md046.js +32 -32
- package/lib/md047.js +28 -28
- package/lib/md048.js +29 -29
- package/lib/rules.js +61 -61
- package/package.json +73 -67
- package/schema/build-config-schema.js +405 -405
- package/schema/markdownlint-config-schema.json +1550 -1550
- package/style/all.json +5 -5
- package/style/cirosantilli.json +22 -22
- package/style/relaxed.json +13 -13
package/lib/md001.js
CHANGED
|
@@ -1,22 +1,22 @@
|
|
|
1
|
-
// @ts-check
|
|
2
|
-
|
|
3
|
-
"use strict";
|
|
4
|
-
|
|
5
|
-
const { addErrorDetailIf, filterTokens } = require("../helpers");
|
|
6
|
-
|
|
7
|
-
module.exports = {
|
|
8
|
-
"names": [ "MD001", "heading-increment", "header-increment" ],
|
|
9
|
-
"description": "Heading levels should only increment by one level at a time",
|
|
10
|
-
"tags": [ "headings", "headers" ],
|
|
11
|
-
"function": function MD001(params, onError) {
|
|
12
|
-
let prevLevel = 0;
|
|
13
|
-
filterTokens(params, "heading_open", function forToken(token) {
|
|
14
|
-
const level = parseInt(token.tag.slice(1), 10);
|
|
15
|
-
if (prevLevel && (level > prevLevel)) {
|
|
16
|
-
addErrorDetailIf(onError, token.lineNumber,
|
|
17
|
-
"h" + (prevLevel + 1), "h" + level);
|
|
18
|
-
}
|
|
19
|
-
prevLevel = level;
|
|
20
|
-
});
|
|
21
|
-
}
|
|
22
|
-
};
|
|
1
|
+
// @ts-check
|
|
2
|
+
|
|
3
|
+
"use strict";
|
|
4
|
+
|
|
5
|
+
const { addErrorDetailIf, filterTokens } = require("../helpers");
|
|
6
|
+
|
|
7
|
+
module.exports = {
|
|
8
|
+
"names": [ "MD001", "heading-increment", "header-increment" ],
|
|
9
|
+
"description": "Heading levels should only increment by one level at a time",
|
|
10
|
+
"tags": [ "headings", "headers" ],
|
|
11
|
+
"function": function MD001(params, onError) {
|
|
12
|
+
let prevLevel = 0;
|
|
13
|
+
filterTokens(params, "heading_open", function forToken(token) {
|
|
14
|
+
const level = parseInt(token.tag.slice(1), 10);
|
|
15
|
+
if (prevLevel && (level > prevLevel)) {
|
|
16
|
+
addErrorDetailIf(onError, token.lineNumber,
|
|
17
|
+
"h" + (prevLevel + 1), "h" + level);
|
|
18
|
+
}
|
|
19
|
+
prevLevel = level;
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
};
|
package/lib/md002.js
CHANGED
|
@@ -1,22 +1,22 @@
|
|
|
1
|
-
// @ts-check
|
|
2
|
-
|
|
3
|
-
"use strict";
|
|
4
|
-
|
|
5
|
-
const { addErrorDetailIf } = require("../helpers");
|
|
6
|
-
|
|
7
|
-
module.exports = {
|
|
8
|
-
"names": [ "MD002", "first-heading-h1", "first-header-h1" ],
|
|
9
|
-
"description": "First heading should be a top level heading",
|
|
10
|
-
"tags": [ "headings", "headers" ],
|
|
11
|
-
"function": function MD002(params, onError) {
|
|
12
|
-
const level = Number(params.config.level || 1);
|
|
13
|
-
const tag = "h" + level;
|
|
14
|
-
params.tokens.every(function forToken(token) {
|
|
15
|
-
if (token.type === "heading_open") {
|
|
16
|
-
addErrorDetailIf(onError, token.lineNumber, tag, token.tag);
|
|
17
|
-
return false;
|
|
18
|
-
}
|
|
19
|
-
return true;
|
|
20
|
-
});
|
|
21
|
-
}
|
|
22
|
-
};
|
|
1
|
+
// @ts-check
|
|
2
|
+
|
|
3
|
+
"use strict";
|
|
4
|
+
|
|
5
|
+
const { addErrorDetailIf } = require("../helpers");
|
|
6
|
+
|
|
7
|
+
module.exports = {
|
|
8
|
+
"names": [ "MD002", "first-heading-h1", "first-header-h1" ],
|
|
9
|
+
"description": "First heading should be a top level heading",
|
|
10
|
+
"tags": [ "headings", "headers" ],
|
|
11
|
+
"function": function MD002(params, onError) {
|
|
12
|
+
const level = Number(params.config.level || 1);
|
|
13
|
+
const tag = "h" + level;
|
|
14
|
+
params.tokens.every(function forToken(token) {
|
|
15
|
+
if (token.type === "heading_open") {
|
|
16
|
+
addErrorDetailIf(onError, token.lineNumber, tag, token.tag);
|
|
17
|
+
return false;
|
|
18
|
+
}
|
|
19
|
+
return true;
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
};
|
package/lib/md003.js
CHANGED
|
@@ -1,42 +1,42 @@
|
|
|
1
|
-
// @ts-check
|
|
2
|
-
|
|
3
|
-
"use strict";
|
|
4
|
-
|
|
5
|
-
const { addErrorDetailIf, filterTokens, headingStyleFor } =
|
|
6
|
-
require("../helpers");
|
|
7
|
-
|
|
8
|
-
module.exports = {
|
|
9
|
-
"names": [ "MD003", "heading-style", "header-style" ],
|
|
10
|
-
"description": "Heading style",
|
|
11
|
-
"tags": [ "headings", "headers" ],
|
|
12
|
-
"function": function MD003(params, onError) {
|
|
13
|
-
let style = String(params.config.style || "consistent");
|
|
14
|
-
filterTokens(params, "heading_open", function forToken(token) {
|
|
15
|
-
const styleForToken = headingStyleFor(token);
|
|
16
|
-
if (style === "consistent") {
|
|
17
|
-
style = styleForToken;
|
|
18
|
-
}
|
|
19
|
-
if (styleForToken !== style) {
|
|
20
|
-
const h12 = /h[12]/.test(token.tag);
|
|
21
|
-
const setextWithAtx =
|
|
22
|
-
(style === "setext_with_atx") &&
|
|
23
|
-
((h12 && (styleForToken === "setext")) ||
|
|
24
|
-
(!h12 && (styleForToken === "atx")));
|
|
25
|
-
const setextWithAtxClosed =
|
|
26
|
-
(style === "setext_with_atx_closed") &&
|
|
27
|
-
((h12 && (styleForToken === "setext")) ||
|
|
28
|
-
(!h12 && (styleForToken === "atx_closed")));
|
|
29
|
-
if (!setextWithAtx && !setextWithAtxClosed) {
|
|
30
|
-
let expected = style;
|
|
31
|
-
if (style === "setext_with_atx") {
|
|
32
|
-
expected = h12 ? "setext" : "atx";
|
|
33
|
-
} else if (style === "setext_with_atx_closed") {
|
|
34
|
-
expected = h12 ? "setext" : "atx_closed";
|
|
35
|
-
}
|
|
36
|
-
addErrorDetailIf(onError, token.lineNumber,
|
|
37
|
-
expected, styleForToken);
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
});
|
|
41
|
-
}
|
|
42
|
-
};
|
|
1
|
+
// @ts-check
|
|
2
|
+
|
|
3
|
+
"use strict";
|
|
4
|
+
|
|
5
|
+
const { addErrorDetailIf, filterTokens, headingStyleFor } =
|
|
6
|
+
require("../helpers");
|
|
7
|
+
|
|
8
|
+
module.exports = {
|
|
9
|
+
"names": [ "MD003", "heading-style", "header-style" ],
|
|
10
|
+
"description": "Heading style",
|
|
11
|
+
"tags": [ "headings", "headers" ],
|
|
12
|
+
"function": function MD003(params, onError) {
|
|
13
|
+
let style = String(params.config.style || "consistent");
|
|
14
|
+
filterTokens(params, "heading_open", function forToken(token) {
|
|
15
|
+
const styleForToken = headingStyleFor(token);
|
|
16
|
+
if (style === "consistent") {
|
|
17
|
+
style = styleForToken;
|
|
18
|
+
}
|
|
19
|
+
if (styleForToken !== style) {
|
|
20
|
+
const h12 = /h[12]/.test(token.tag);
|
|
21
|
+
const setextWithAtx =
|
|
22
|
+
(style === "setext_with_atx") &&
|
|
23
|
+
((h12 && (styleForToken === "setext")) ||
|
|
24
|
+
(!h12 && (styleForToken === "atx")));
|
|
25
|
+
const setextWithAtxClosed =
|
|
26
|
+
(style === "setext_with_atx_closed") &&
|
|
27
|
+
((h12 && (styleForToken === "setext")) ||
|
|
28
|
+
(!h12 && (styleForToken === "atx_closed")));
|
|
29
|
+
if (!setextWithAtx && !setextWithAtxClosed) {
|
|
30
|
+
let expected = style;
|
|
31
|
+
if (style === "setext_with_atx") {
|
|
32
|
+
expected = h12 ? "setext" : "atx";
|
|
33
|
+
} else if (style === "setext_with_atx_closed") {
|
|
34
|
+
expected = h12 ? "setext" : "atx_closed";
|
|
35
|
+
}
|
|
36
|
+
addErrorDetailIf(onError, token.lineNumber,
|
|
37
|
+
expected, styleForToken);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
};
|
package/lib/md004.js
CHANGED
|
@@ -1,43 +1,43 @@
|
|
|
1
|
-
// @ts-check
|
|
2
|
-
|
|
3
|
-
"use strict";
|
|
4
|
-
|
|
5
|
-
const { addErrorDetailIf, listItemMarkerRe,
|
|
6
|
-
rangeFromRegExp, unorderedListStyleFor } = require("../helpers");
|
|
7
|
-
const { flattenedLists } = require("./cache");
|
|
8
|
-
|
|
9
|
-
module.exports = {
|
|
10
|
-
"names": [ "MD004", "ul-style" ],
|
|
11
|
-
"description": "Unordered list style",
|
|
12
|
-
"tags": [ "bullet", "ul" ],
|
|
13
|
-
"function": function MD004(params, onError) {
|
|
14
|
-
const style = String(params.config.style || "consistent");
|
|
15
|
-
let expectedStyle = style;
|
|
16
|
-
const nestingStyles = [];
|
|
17
|
-
flattenedLists().forEach((list) => {
|
|
18
|
-
if (list.unordered) {
|
|
19
|
-
if (expectedStyle === "consistent") {
|
|
20
|
-
expectedStyle = unorderedListStyleFor(list.items[0]);
|
|
21
|
-
}
|
|
22
|
-
list.items.forEach((item) => {
|
|
23
|
-
const itemStyle = unorderedListStyleFor(item);
|
|
24
|
-
if (style === "sublist") {
|
|
25
|
-
const nesting = list.nesting;
|
|
26
|
-
if (!nestingStyles[nesting] &&
|
|
27
|
-
(itemStyle !== nestingStyles[nesting - 1])) {
|
|
28
|
-
nestingStyles[nesting] = itemStyle;
|
|
29
|
-
} else {
|
|
30
|
-
addErrorDetailIf(onError, item.lineNumber,
|
|
31
|
-
nestingStyles[nesting], itemStyle, null, null,
|
|
32
|
-
rangeFromRegExp(item.line, listItemMarkerRe));
|
|
33
|
-
}
|
|
34
|
-
} else {
|
|
35
|
-
addErrorDetailIf(onError, item.lineNumber,
|
|
36
|
-
expectedStyle, itemStyle, null, null,
|
|
37
|
-
rangeFromRegExp(item.line, listItemMarkerRe));
|
|
38
|
-
}
|
|
39
|
-
});
|
|
40
|
-
}
|
|
41
|
-
});
|
|
42
|
-
}
|
|
43
|
-
};
|
|
1
|
+
// @ts-check
|
|
2
|
+
|
|
3
|
+
"use strict";
|
|
4
|
+
|
|
5
|
+
const { addErrorDetailIf, listItemMarkerRe,
|
|
6
|
+
rangeFromRegExp, unorderedListStyleFor } = require("../helpers");
|
|
7
|
+
const { flattenedLists } = require("./cache");
|
|
8
|
+
|
|
9
|
+
module.exports = {
|
|
10
|
+
"names": [ "MD004", "ul-style" ],
|
|
11
|
+
"description": "Unordered list style",
|
|
12
|
+
"tags": [ "bullet", "ul" ],
|
|
13
|
+
"function": function MD004(params, onError) {
|
|
14
|
+
const style = String(params.config.style || "consistent");
|
|
15
|
+
let expectedStyle = style;
|
|
16
|
+
const nestingStyles = [];
|
|
17
|
+
flattenedLists().forEach((list) => {
|
|
18
|
+
if (list.unordered) {
|
|
19
|
+
if (expectedStyle === "consistent") {
|
|
20
|
+
expectedStyle = unorderedListStyleFor(list.items[0]);
|
|
21
|
+
}
|
|
22
|
+
list.items.forEach((item) => {
|
|
23
|
+
const itemStyle = unorderedListStyleFor(item);
|
|
24
|
+
if (style === "sublist") {
|
|
25
|
+
const nesting = list.nesting;
|
|
26
|
+
if (!nestingStyles[nesting] &&
|
|
27
|
+
(itemStyle !== nestingStyles[nesting - 1])) {
|
|
28
|
+
nestingStyles[nesting] = itemStyle;
|
|
29
|
+
} else {
|
|
30
|
+
addErrorDetailIf(onError, item.lineNumber,
|
|
31
|
+
nestingStyles[nesting], itemStyle, null, null,
|
|
32
|
+
rangeFromRegExp(item.line, listItemMarkerRe));
|
|
33
|
+
}
|
|
34
|
+
} else {
|
|
35
|
+
addErrorDetailIf(onError, item.lineNumber,
|
|
36
|
+
expectedStyle, itemStyle, null, null,
|
|
37
|
+
rangeFromRegExp(item.line, listItemMarkerRe));
|
|
38
|
+
}
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
};
|
package/lib/md005.js
CHANGED
|
@@ -1,69 +1,69 @@
|
|
|
1
|
-
// @ts-check
|
|
2
|
-
|
|
3
|
-
"use strict";
|
|
4
|
-
|
|
5
|
-
const { addError, addErrorDetailIf, indentFor, listItemMarkerRe,
|
|
6
|
-
orderedListItemMarkerRe, rangeFromRegExp } = require("../helpers");
|
|
7
|
-
const { flattenedLists } = require("./cache");
|
|
8
|
-
|
|
9
|
-
module.exports = {
|
|
10
|
-
"names": [ "MD005", "list-indent" ],
|
|
11
|
-
"description": "Inconsistent indentation for list items at the same level",
|
|
12
|
-
"tags": [ "bullet", "ul", "indentation" ],
|
|
13
|
-
"function": function MD005(params, onError) {
|
|
14
|
-
flattenedLists().forEach((list) => {
|
|
15
|
-
const expectedIndent = list.indent;
|
|
16
|
-
let expectedEnd = 0;
|
|
17
|
-
let actualEnd = -1;
|
|
18
|
-
let endMatching = false;
|
|
19
|
-
list.items.forEach((item) => {
|
|
20
|
-
const { line, lineNumber } = item;
|
|
21
|
-
const actualIndent = indentFor(item);
|
|
22
|
-
let match = null;
|
|
23
|
-
if (list.unordered) {
|
|
24
|
-
addErrorDetailIf(
|
|
25
|
-
onError,
|
|
26
|
-
lineNumber,
|
|
27
|
-
expectedIndent,
|
|
28
|
-
actualIndent,
|
|
29
|
-
null,
|
|
30
|
-
null,
|
|
31
|
-
rangeFromRegExp(line, listItemMarkerRe)
|
|
32
|
-
// No fixInfo; MD007 handles this scenario better
|
|
33
|
-
);
|
|
34
|
-
} else if ((match = orderedListItemMarkerRe.exec(line))) {
|
|
35
|
-
actualEnd = match[0].length;
|
|
36
|
-
expectedEnd = expectedEnd || actualEnd;
|
|
37
|
-
const markerLength = match[1].length + 1;
|
|
38
|
-
if ((expectedIndent !== actualIndent) || endMatching) {
|
|
39
|
-
if (expectedEnd === actualEnd) {
|
|
40
|
-
endMatching = true;
|
|
41
|
-
} else {
|
|
42
|
-
const detail = endMatching ?
|
|
43
|
-
`Expected: (${expectedEnd}); Actual: (${actualEnd})` :
|
|
44
|
-
`Expected: ${expectedIndent}; Actual: ${actualIndent}`;
|
|
45
|
-
const expected = endMatching ?
|
|
46
|
-
expectedEnd - markerLength :
|
|
47
|
-
expectedIndent;
|
|
48
|
-
const actual = endMatching ?
|
|
49
|
-
actualEnd - markerLength :
|
|
50
|
-
actualIndent;
|
|
51
|
-
addError(
|
|
52
|
-
onError,
|
|
53
|
-
lineNumber,
|
|
54
|
-
detail,
|
|
55
|
-
null,
|
|
56
|
-
rangeFromRegExp(line, listItemMarkerRe),
|
|
57
|
-
{
|
|
58
|
-
"editColumn": Math.min(actual, expected) + 1,
|
|
59
|
-
"deleteCount": Math.max(actual - expected, 0),
|
|
60
|
-
"insertText": "".padEnd(Math.max(expected - actual, 0))
|
|
61
|
-
}
|
|
62
|
-
);
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
});
|
|
67
|
-
});
|
|
68
|
-
}
|
|
69
|
-
};
|
|
1
|
+
// @ts-check
|
|
2
|
+
|
|
3
|
+
"use strict";
|
|
4
|
+
|
|
5
|
+
const { addError, addErrorDetailIf, indentFor, listItemMarkerRe,
|
|
6
|
+
orderedListItemMarkerRe, rangeFromRegExp } = require("../helpers");
|
|
7
|
+
const { flattenedLists } = require("./cache");
|
|
8
|
+
|
|
9
|
+
module.exports = {
|
|
10
|
+
"names": [ "MD005", "list-indent" ],
|
|
11
|
+
"description": "Inconsistent indentation for list items at the same level",
|
|
12
|
+
"tags": [ "bullet", "ul", "indentation" ],
|
|
13
|
+
"function": function MD005(params, onError) {
|
|
14
|
+
flattenedLists().forEach((list) => {
|
|
15
|
+
const expectedIndent = list.indent;
|
|
16
|
+
let expectedEnd = 0;
|
|
17
|
+
let actualEnd = -1;
|
|
18
|
+
let endMatching = false;
|
|
19
|
+
list.items.forEach((item) => {
|
|
20
|
+
const { line, lineNumber } = item;
|
|
21
|
+
const actualIndent = indentFor(item);
|
|
22
|
+
let match = null;
|
|
23
|
+
if (list.unordered) {
|
|
24
|
+
addErrorDetailIf(
|
|
25
|
+
onError,
|
|
26
|
+
lineNumber,
|
|
27
|
+
expectedIndent,
|
|
28
|
+
actualIndent,
|
|
29
|
+
null,
|
|
30
|
+
null,
|
|
31
|
+
rangeFromRegExp(line, listItemMarkerRe)
|
|
32
|
+
// No fixInfo; MD007 handles this scenario better
|
|
33
|
+
);
|
|
34
|
+
} else if ((match = orderedListItemMarkerRe.exec(line))) {
|
|
35
|
+
actualEnd = match[0].length;
|
|
36
|
+
expectedEnd = expectedEnd || actualEnd;
|
|
37
|
+
const markerLength = match[1].length + 1;
|
|
38
|
+
if ((expectedIndent !== actualIndent) || endMatching) {
|
|
39
|
+
if (expectedEnd === actualEnd) {
|
|
40
|
+
endMatching = true;
|
|
41
|
+
} else {
|
|
42
|
+
const detail = endMatching ?
|
|
43
|
+
`Expected: (${expectedEnd}); Actual: (${actualEnd})` :
|
|
44
|
+
`Expected: ${expectedIndent}; Actual: ${actualIndent}`;
|
|
45
|
+
const expected = endMatching ?
|
|
46
|
+
expectedEnd - markerLength :
|
|
47
|
+
expectedIndent;
|
|
48
|
+
const actual = endMatching ?
|
|
49
|
+
actualEnd - markerLength :
|
|
50
|
+
actualIndent;
|
|
51
|
+
addError(
|
|
52
|
+
onError,
|
|
53
|
+
lineNumber,
|
|
54
|
+
detail,
|
|
55
|
+
null,
|
|
56
|
+
rangeFromRegExp(line, listItemMarkerRe),
|
|
57
|
+
{
|
|
58
|
+
"editColumn": Math.min(actual, expected) + 1,
|
|
59
|
+
"deleteCount": Math.max(actual - expected, 0),
|
|
60
|
+
"insertText": "".padEnd(Math.max(expected - actual, 0))
|
|
61
|
+
}
|
|
62
|
+
);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
});
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
};
|
package/lib/md006.js
CHANGED
|
@@ -1,34 +1,34 @@
|
|
|
1
|
-
// @ts-check
|
|
2
|
-
|
|
3
|
-
"use strict";
|
|
4
|
-
|
|
5
|
-
const { addErrorDetailIf, listItemMarkerRe, rangeFromRegExp } =
|
|
6
|
-
require("../helpers");
|
|
7
|
-
const { flattenedLists } = require("./cache");
|
|
8
|
-
|
|
9
|
-
module.exports = {
|
|
10
|
-
"names": [ "MD006", "ul-start-left" ],
|
|
11
|
-
"description":
|
|
12
|
-
"Consider starting bulleted lists at the beginning of the line",
|
|
13
|
-
"tags": [ "bullet", "ul", "indentation" ],
|
|
14
|
-
"function": function MD006(params, onError) {
|
|
15
|
-
flattenedLists().forEach((list) => {
|
|
16
|
-
if (list.unordered && !list.nesting && (list.indent !== 0)) {
|
|
17
|
-
list.items.forEach((item) => {
|
|
18
|
-
const { lineNumber, line } = item;
|
|
19
|
-
addErrorDetailIf(
|
|
20
|
-
onError,
|
|
21
|
-
lineNumber,
|
|
22
|
-
0,
|
|
23
|
-
list.indent,
|
|
24
|
-
null,
|
|
25
|
-
null,
|
|
26
|
-
rangeFromRegExp(line, listItemMarkerRe),
|
|
27
|
-
{
|
|
28
|
-
"deleteCount": line.length - line.trimLeft().length
|
|
29
|
-
});
|
|
30
|
-
});
|
|
31
|
-
}
|
|
32
|
-
});
|
|
33
|
-
}
|
|
34
|
-
};
|
|
1
|
+
// @ts-check
|
|
2
|
+
|
|
3
|
+
"use strict";
|
|
4
|
+
|
|
5
|
+
const { addErrorDetailIf, listItemMarkerRe, rangeFromRegExp } =
|
|
6
|
+
require("../helpers");
|
|
7
|
+
const { flattenedLists } = require("./cache");
|
|
8
|
+
|
|
9
|
+
module.exports = {
|
|
10
|
+
"names": [ "MD006", "ul-start-left" ],
|
|
11
|
+
"description":
|
|
12
|
+
"Consider starting bulleted lists at the beginning of the line",
|
|
13
|
+
"tags": [ "bullet", "ul", "indentation" ],
|
|
14
|
+
"function": function MD006(params, onError) {
|
|
15
|
+
flattenedLists().forEach((list) => {
|
|
16
|
+
if (list.unordered && !list.nesting && (list.indent !== 0)) {
|
|
17
|
+
list.items.forEach((item) => {
|
|
18
|
+
const { lineNumber, line } = item;
|
|
19
|
+
addErrorDetailIf(
|
|
20
|
+
onError,
|
|
21
|
+
lineNumber,
|
|
22
|
+
0,
|
|
23
|
+
list.indent,
|
|
24
|
+
null,
|
|
25
|
+
null,
|
|
26
|
+
rangeFromRegExp(line, listItemMarkerRe),
|
|
27
|
+
{
|
|
28
|
+
"deleteCount": line.length - line.trimLeft().length
|
|
29
|
+
});
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
};
|
package/lib/md007.js
CHANGED
|
@@ -1,47 +1,47 @@
|
|
|
1
|
-
// @ts-check
|
|
2
|
-
|
|
3
|
-
"use strict";
|
|
4
|
-
|
|
5
|
-
const { addErrorDetailIf, indentFor, listItemMarkerRe } =
|
|
6
|
-
require("../helpers");
|
|
7
|
-
const { flattenedLists } = require("./cache");
|
|
8
|
-
|
|
9
|
-
module.exports = {
|
|
10
|
-
"names": [ "MD007", "ul-indent" ],
|
|
11
|
-
"description": "Unordered list indentation",
|
|
12
|
-
"tags": [ "bullet", "ul", "indentation" ],
|
|
13
|
-
"function": function MD007(params, onError) {
|
|
14
|
-
const indent = Number(params.config.indent || 2);
|
|
15
|
-
const startIndented = !!params.config.start_indented;
|
|
16
|
-
flattenedLists().forEach((list) => {
|
|
17
|
-
if (list.unordered && list.parentsUnordered) {
|
|
18
|
-
list.items.forEach((item) => {
|
|
19
|
-
const { lineNumber, line } = item;
|
|
20
|
-
const expectedNesting = list.nesting + (startIndented ? 1 : 0);
|
|
21
|
-
const expectedIndent = expectedNesting * indent;
|
|
22
|
-
const actualIndent = indentFor(item);
|
|
23
|
-
let range = null;
|
|
24
|
-
let editColumn = 1;
|
|
25
|
-
const match = line.match(listItemMarkerRe);
|
|
26
|
-
if (match) {
|
|
27
|
-
range = [ 1, match[0].length ];
|
|
28
|
-
editColumn += match[1].length - actualIndent;
|
|
29
|
-
}
|
|
30
|
-
addErrorDetailIf(
|
|
31
|
-
onError,
|
|
32
|
-
lineNumber,
|
|
33
|
-
expectedIndent,
|
|
34
|
-
actualIndent,
|
|
35
|
-
null,
|
|
36
|
-
null,
|
|
37
|
-
range,
|
|
38
|
-
{
|
|
39
|
-
editColumn,
|
|
40
|
-
"deleteCount": actualIndent,
|
|
41
|
-
"insertText": "".padEnd(expectedIndent)
|
|
42
|
-
});
|
|
43
|
-
});
|
|
44
|
-
}
|
|
45
|
-
});
|
|
46
|
-
}
|
|
47
|
-
};
|
|
1
|
+
// @ts-check
|
|
2
|
+
|
|
3
|
+
"use strict";
|
|
4
|
+
|
|
5
|
+
const { addErrorDetailIf, indentFor, listItemMarkerRe } =
|
|
6
|
+
require("../helpers");
|
|
7
|
+
const { flattenedLists } = require("./cache");
|
|
8
|
+
|
|
9
|
+
module.exports = {
|
|
10
|
+
"names": [ "MD007", "ul-indent" ],
|
|
11
|
+
"description": "Unordered list indentation",
|
|
12
|
+
"tags": [ "bullet", "ul", "indentation" ],
|
|
13
|
+
"function": function MD007(params, onError) {
|
|
14
|
+
const indent = Number(params.config.indent || 2);
|
|
15
|
+
const startIndented = !!params.config.start_indented;
|
|
16
|
+
flattenedLists().forEach((list) => {
|
|
17
|
+
if (list.unordered && list.parentsUnordered) {
|
|
18
|
+
list.items.forEach((item) => {
|
|
19
|
+
const { lineNumber, line } = item;
|
|
20
|
+
const expectedNesting = list.nesting + (startIndented ? 1 : 0);
|
|
21
|
+
const expectedIndent = expectedNesting * indent;
|
|
22
|
+
const actualIndent = indentFor(item);
|
|
23
|
+
let range = null;
|
|
24
|
+
let editColumn = 1;
|
|
25
|
+
const match = line.match(listItemMarkerRe);
|
|
26
|
+
if (match) {
|
|
27
|
+
range = [ 1, match[0].length ];
|
|
28
|
+
editColumn += match[1].length - actualIndent;
|
|
29
|
+
}
|
|
30
|
+
addErrorDetailIf(
|
|
31
|
+
onError,
|
|
32
|
+
lineNumber,
|
|
33
|
+
expectedIndent,
|
|
34
|
+
actualIndent,
|
|
35
|
+
null,
|
|
36
|
+
null,
|
|
37
|
+
range,
|
|
38
|
+
{
|
|
39
|
+
editColumn,
|
|
40
|
+
"deleteCount": actualIndent,
|
|
41
|
+
"insertText": "".padEnd(expectedIndent)
|
|
42
|
+
});
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
};
|