@alexlit/lint-kit 127.2.0 → 127.3.0
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/package.json +1 -1
- package/packages/config-markdownlint/node_modules/markdownlint/CHANGELOG.md +457 -0
- package/packages/config-markdownlint/node_modules/markdownlint/CONTRIBUTING.md +93 -0
- package/packages/config-markdownlint/node_modules/markdownlint/LICENSE +21 -0
- package/packages/config-markdownlint/node_modules/markdownlint/README.md +1047 -0
- package/packages/config-markdownlint/node_modules/markdownlint/demo/markdownlint-browser.js +7094 -0
- package/packages/config-markdownlint/node_modules/markdownlint/doc/CustomRules.md +388 -0
- package/packages/config-markdownlint/node_modules/markdownlint/doc/Prettier.md +27 -0
- package/packages/config-markdownlint/node_modules/markdownlint/doc/ReleaseProcess.md +20 -0
- package/packages/config-markdownlint/node_modules/markdownlint/doc/Rules.md +2528 -0
- package/packages/config-markdownlint/node_modules/markdownlint/doc/md001.md +37 -0
- package/packages/config-markdownlint/node_modules/markdownlint/doc/md003.md +59 -0
- package/packages/config-markdownlint/node_modules/markdownlint/doc/md004.md +49 -0
- package/packages/config-markdownlint/node_modules/markdownlint/doc/md005.md +53 -0
- package/packages/config-markdownlint/node_modules/markdownlint/doc/md007.md +52 -0
- package/packages/config-markdownlint/node_modules/markdownlint/doc/md009.md +51 -0
- package/packages/config-markdownlint/node_modules/markdownlint/doc/md010.md +56 -0
- package/packages/config-markdownlint/node_modules/markdownlint/doc/md011.md +30 -0
- package/packages/config-markdownlint/node_modules/markdownlint/doc/md012.md +38 -0
- package/packages/config-markdownlint/node_modules/markdownlint/doc/md013.md +58 -0
- package/packages/config-markdownlint/node_modules/markdownlint/doc/md014.md +54 -0
- package/packages/config-markdownlint/node_modules/markdownlint/doc/md018.md +27 -0
- package/packages/config-markdownlint/node_modules/markdownlint/doc/md019.md +28 -0
- package/packages/config-markdownlint/node_modules/markdownlint/doc/md020.md +29 -0
- package/packages/config-markdownlint/node_modules/markdownlint/doc/md021.md +31 -0
- package/packages/config-markdownlint/node_modules/markdownlint/doc/md022.md +52 -0
- package/packages/config-markdownlint/node_modules/markdownlint/doc/md023.md +33 -0
- package/packages/config-markdownlint/node_modules/markdownlint/doc/md024.md +44 -0
- package/packages/config-markdownlint/node_modules/markdownlint/doc/md025.md +49 -0
- package/packages/config-markdownlint/node_modules/markdownlint/doc/md026.md +40 -0
- package/packages/config-markdownlint/node_modules/markdownlint/doc/md027.md +24 -0
- package/packages/config-markdownlint/node_modules/markdownlint/doc/md028.md +40 -0
- package/packages/config-markdownlint/node_modules/markdownlint/doc/md029.md +98 -0
- package/packages/config-markdownlint/node_modules/markdownlint/doc/md030.md +82 -0
- package/packages/config-markdownlint/node_modules/markdownlint/doc/md031.md +50 -0
- package/packages/config-markdownlint/node_modules/markdownlint/doc/md032.md +55 -0
- package/packages/config-markdownlint/node_modules/markdownlint/doc/md033.md +27 -0
- package/packages/config-markdownlint/node_modules/markdownlint/doc/md034.md +55 -0
- package/packages/config-markdownlint/node_modules/markdownlint/doc/md035.md +42 -0
- package/packages/config-markdownlint/node_modules/markdownlint/doc/md036.md +45 -0
- package/packages/config-markdownlint/node_modules/markdownlint/doc/md037.md +37 -0
- package/packages/config-markdownlint/node_modules/markdownlint/doc/md038.md +40 -0
- package/packages/config-markdownlint/node_modules/markdownlint/doc/md039.md +21 -0
- package/packages/config-markdownlint/node_modules/markdownlint/doc/md040.md +52 -0
- package/packages/config-markdownlint/node_modules/markdownlint/doc/md041.md +49 -0
- package/packages/config-markdownlint/node_modules/markdownlint/doc/md042.md +32 -0
- package/packages/config-markdownlint/node_modules/markdownlint/doc/md043.md +69 -0
- package/packages/config-markdownlint/node_modules/markdownlint/doc/md044.md +45 -0
- package/packages/config-markdownlint/node_modules/markdownlint/doc/md045.md +40 -0
- package/packages/config-markdownlint/node_modules/markdownlint/doc/md046.md +40 -0
- package/packages/config-markdownlint/node_modules/markdownlint/doc/md047.md +34 -0
- package/packages/config-markdownlint/node_modules/markdownlint/doc/md048.md +41 -0
- package/packages/config-markdownlint/node_modules/markdownlint/doc/md049.md +35 -0
- package/packages/config-markdownlint/node_modules/markdownlint/doc/md050.md +35 -0
- package/packages/config-markdownlint/node_modules/markdownlint/doc/md051.md +87 -0
- package/packages/config-markdownlint/node_modules/markdownlint/doc/md052.md +40 -0
- package/packages/config-markdownlint/node_modules/markdownlint/doc/md053.md +38 -0
- package/packages/config-markdownlint/node_modules/markdownlint/doc/md054.md +100 -0
- package/packages/config-markdownlint/node_modules/markdownlint/doc/md055.md +54 -0
- package/packages/config-markdownlint/node_modules/markdownlint/doc/md056.md +37 -0
- package/packages/config-markdownlint/node_modules/markdownlint/doc/md058.md +48 -0
- package/packages/config-markdownlint/node_modules/markdownlint/helpers/LICENSE +21 -0
- package/packages/config-markdownlint/node_modules/markdownlint/helpers/README.md +46 -0
- package/packages/config-markdownlint/node_modules/markdownlint/helpers/helpers.js +793 -0
- package/packages/config-markdownlint/node_modules/markdownlint/helpers/micromark.cjs +544 -0
- package/packages/config-markdownlint/node_modules/markdownlint/helpers/package.json +26 -0
- package/packages/config-markdownlint/node_modules/markdownlint/helpers/shared.js +10 -0
- package/packages/config-markdownlint/node_modules/markdownlint/lib/cache.js +70 -0
- package/packages/config-markdownlint/node_modules/markdownlint/lib/configuration-strict.d.ts +1185 -0
- package/packages/config-markdownlint/node_modules/markdownlint/lib/configuration.d.ts +8 -0
- package/packages/config-markdownlint/node_modules/markdownlint/lib/constants.js +15 -0
- package/packages/config-markdownlint/node_modules/markdownlint/lib/markdownlint.d.ts +488 -0
- package/packages/config-markdownlint/node_modules/markdownlint/lib/markdownlint.js +1572 -0
- package/packages/config-markdownlint/node_modules/markdownlint/lib/md001.js +31 -0
- package/packages/config-markdownlint/node_modules/markdownlint/lib/md003.js +50 -0
- package/packages/config-markdownlint/node_modules/markdownlint/lib/md004.js +86 -0
- package/packages/config-markdownlint/node_modules/markdownlint/lib/md005.js +72 -0
- package/packages/config-markdownlint/node_modules/markdownlint/lib/md007.js +88 -0
- package/packages/config-markdownlint/node_modules/markdownlint/lib/md009.js +95 -0
- package/packages/config-markdownlint/node_modules/markdownlint/lib/md010.js +78 -0
- package/packages/config-markdownlint/node_modules/markdownlint/lib/md011.js +57 -0
- package/packages/config-markdownlint/node_modules/markdownlint/lib/md012.js +43 -0
- package/packages/config-markdownlint/node_modules/markdownlint/lib/md013.js +105 -0
- package/packages/config-markdownlint/node_modules/markdownlint/lib/md014.js +54 -0
- package/packages/config-markdownlint/node_modules/markdownlint/lib/md018.js +46 -0
- package/packages/config-markdownlint/node_modules/markdownlint/lib/md019-md021.js +80 -0
- package/packages/config-markdownlint/node_modules/markdownlint/lib/md020.js +71 -0
- package/packages/config-markdownlint/node_modules/markdownlint/lib/md022.js +106 -0
- package/packages/config-markdownlint/node_modules/markdownlint/lib/md023.js +40 -0
- package/packages/config-markdownlint/node_modules/markdownlint/lib/md024.js +48 -0
- package/packages/config-markdownlint/node_modules/markdownlint/lib/md025.js +40 -0
- package/packages/config-markdownlint/node_modules/markdownlint/lib/md026.js +49 -0
- package/packages/config-markdownlint/node_modules/markdownlint/lib/md027.js +37 -0
- package/packages/config-markdownlint/node_modules/markdownlint/lib/md028.js +42 -0
- package/packages/config-markdownlint/node_modules/markdownlint/lib/md029.js +76 -0
- package/packages/config-markdownlint/node_modules/markdownlint/lib/md030.js +60 -0
- package/packages/config-markdownlint/node_modules/markdownlint/lib/md031.js +63 -0
- package/packages/config-markdownlint/node_modules/markdownlint/lib/md032.js +66 -0
- package/packages/config-markdownlint/node_modules/markdownlint/lib/md033.js +41 -0
- package/packages/config-markdownlint/node_modules/markdownlint/lib/md034.js +100 -0
- package/packages/config-markdownlint/node_modules/markdownlint/lib/md035.js +26 -0
- package/packages/config-markdownlint/node_modules/markdownlint/lib/md036.js +51 -0
- package/packages/config-markdownlint/node_modules/markdownlint/lib/md037.js +94 -0
- package/packages/config-markdownlint/node_modules/markdownlint/lib/md038.js +100 -0
- package/packages/config-markdownlint/node_modules/markdownlint/lib/md039.js +83 -0
- package/packages/config-markdownlint/node_modules/markdownlint/lib/md040.js +37 -0
- package/packages/config-markdownlint/node_modules/markdownlint/lib/md041.js +37 -0
- package/packages/config-markdownlint/node_modules/markdownlint/lib/md042.js +63 -0
- package/packages/config-markdownlint/node_modules/markdownlint/lib/md043.js +73 -0
- package/packages/config-markdownlint/node_modules/markdownlint/lib/md044.js +110 -0
- package/packages/config-markdownlint/node_modules/markdownlint/lib/md045.js +62 -0
- package/packages/config-markdownlint/node_modules/markdownlint/lib/md046.js +34 -0
- package/packages/config-markdownlint/node_modules/markdownlint/lib/md047.js +31 -0
- package/packages/config-markdownlint/node_modules/markdownlint/lib/md048.js +39 -0
- package/packages/config-markdownlint/node_modules/markdownlint/lib/md049-md050.js +103 -0
- package/packages/config-markdownlint/node_modules/markdownlint/lib/md051.js +170 -0
- package/packages/config-markdownlint/node_modules/markdownlint/lib/md052.js +42 -0
- package/packages/config-markdownlint/node_modules/markdownlint/lib/md053.js +62 -0
- package/packages/config-markdownlint/node_modules/markdownlint/lib/md054.js +125 -0
- package/packages/config-markdownlint/node_modules/markdownlint/lib/md055.js +79 -0
- package/packages/config-markdownlint/node_modules/markdownlint/lib/md056.js +56 -0
- package/packages/config-markdownlint/node_modules/markdownlint/lib/md058.js +43 -0
- package/packages/config-markdownlint/node_modules/markdownlint/lib/rules.js +74 -0
- package/packages/config-markdownlint/node_modules/markdownlint/package.json +105 -0
- package/packages/config-markdownlint/node_modules/markdownlint/schema/.markdownlint.jsonc +307 -0
- package/packages/config-markdownlint/node_modules/markdownlint/schema/.markdownlint.yaml +275 -0
- package/packages/config-markdownlint/node_modules/markdownlint/schema/ValidatingConfiguration.md +26 -0
- package/packages/config-markdownlint/node_modules/markdownlint/schema/markdownlint-config-schema-strict.json +1819 -0
- package/packages/config-markdownlint/node_modules/markdownlint/schema/markdownlint-config-schema.json +1824 -0
- package/packages/config-markdownlint/node_modules/markdownlint/style/all.json +5 -0
- package/packages/config-markdownlint/node_modules/markdownlint/style/cirosantilli.json +22 -0
- package/packages/config-markdownlint/node_modules/markdownlint/style/prettier.json +27 -0
- package/packages/config-markdownlint/node_modules/markdownlint/style/relaxed.json +12 -0
- package/packages/config-markdownlint/node_modules/markdownlint-micromark/LICENSE +21 -0
- package/packages/config-markdownlint/node_modules/markdownlint-micromark/README.md +10 -0
- package/packages/config-markdownlint/node_modules/markdownlint-micromark/micromark-browser.js +2 -0
- package/packages/config-markdownlint/node_modules/markdownlint-micromark/micromark-html-browser.js +2 -0
- package/packages/config-markdownlint/node_modules/markdownlint-micromark/micromark.cjs +1 -0
- package/packages/config-markdownlint/node_modules/markdownlint-micromark/micromark.d.cts +1751 -0
- package/packages/config-markdownlint/node_modules/markdownlint-micromark/package.json +46 -0
- package/packages/config-markdownlint/package.json +2 -2
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
// @ts-check
|
|
2
|
+
|
|
3
|
+
"use strict";
|
|
4
|
+
|
|
5
|
+
const { addErrorDetailIf } = require("../helpers");
|
|
6
|
+
const { getHeadingLevel } = require("../helpers/micromark.cjs");
|
|
7
|
+
const { filterByTypesCached } = require("./cache");
|
|
8
|
+
|
|
9
|
+
// eslint-disable-next-line jsdoc/valid-types
|
|
10
|
+
/** @type import("./markdownlint").Rule */
|
|
11
|
+
module.exports = {
|
|
12
|
+
"names": [ "MD001", "heading-increment" ],
|
|
13
|
+
"description": "Heading levels should only increment by one level at a time",
|
|
14
|
+
"tags": [ "headings" ],
|
|
15
|
+
"parser": "micromark",
|
|
16
|
+
"function": function MD001(params, onError) {
|
|
17
|
+
let prevLevel = Number.MAX_SAFE_INTEGER;
|
|
18
|
+
for (const heading of filterByTypesCached([ "atxHeading", "setextHeading" ])) {
|
|
19
|
+
const level = getHeadingLevel(heading);
|
|
20
|
+
if (level > prevLevel) {
|
|
21
|
+
addErrorDetailIf(
|
|
22
|
+
onError,
|
|
23
|
+
heading.startLine,
|
|
24
|
+
`h${prevLevel + 1}`,
|
|
25
|
+
`h${level}`
|
|
26
|
+
);
|
|
27
|
+
}
|
|
28
|
+
prevLevel = level;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
};
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
// @ts-check
|
|
2
|
+
|
|
3
|
+
"use strict";
|
|
4
|
+
|
|
5
|
+
const { addErrorDetailIf } = require("../helpers");
|
|
6
|
+
const { getHeadingLevel, getHeadingStyle } = require("../helpers/micromark.cjs");
|
|
7
|
+
const { filterByTypesCached } = require("./cache");
|
|
8
|
+
|
|
9
|
+
// eslint-disable-next-line jsdoc/valid-types
|
|
10
|
+
/** @type import("./markdownlint").Rule */
|
|
11
|
+
module.exports = {
|
|
12
|
+
"names": [ "MD003", "heading-style" ],
|
|
13
|
+
"description": "Heading style",
|
|
14
|
+
"tags": [ "headings" ],
|
|
15
|
+
"parser": "micromark",
|
|
16
|
+
"function": function MD003(params, onError) {
|
|
17
|
+
let style = String(params.config.style || "consistent");
|
|
18
|
+
for (const heading of filterByTypesCached([ "atxHeading", "setextHeading" ])) {
|
|
19
|
+
const styleForToken = getHeadingStyle(heading);
|
|
20
|
+
if (style === "consistent") {
|
|
21
|
+
style = styleForToken;
|
|
22
|
+
}
|
|
23
|
+
if (styleForToken !== style) {
|
|
24
|
+
const h12 = getHeadingLevel(heading) <= 2;
|
|
25
|
+
const setextWithAtx =
|
|
26
|
+
(style === "setext_with_atx") &&
|
|
27
|
+
((h12 && (styleForToken === "setext")) ||
|
|
28
|
+
(!h12 && (styleForToken === "atx")));
|
|
29
|
+
const setextWithAtxClosed =
|
|
30
|
+
(style === "setext_with_atx_closed") &&
|
|
31
|
+
((h12 && (styleForToken === "setext")) ||
|
|
32
|
+
(!h12 && (styleForToken === "atx_closed")));
|
|
33
|
+
if (!setextWithAtx && !setextWithAtxClosed) {
|
|
34
|
+
let expected = style;
|
|
35
|
+
if (style === "setext_with_atx") {
|
|
36
|
+
expected = h12 ? "setext" : "atx";
|
|
37
|
+
} else if (style === "setext_with_atx_closed") {
|
|
38
|
+
expected = h12 ? "setext" : "atx_closed";
|
|
39
|
+
}
|
|
40
|
+
addErrorDetailIf(
|
|
41
|
+
onError,
|
|
42
|
+
heading.startLine,
|
|
43
|
+
expected,
|
|
44
|
+
styleForToken
|
|
45
|
+
);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
};
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
// @ts-check
|
|
2
|
+
|
|
3
|
+
"use strict";
|
|
4
|
+
|
|
5
|
+
const { addErrorDetailIf } = require("../helpers");
|
|
6
|
+
const { getDescendantsByType, getTokenParentOfType } = require("../helpers/micromark.cjs");
|
|
7
|
+
const { filterByTypesCached } = require("./cache");
|
|
8
|
+
|
|
9
|
+
const markerToStyle = {
|
|
10
|
+
"-": "dash",
|
|
11
|
+
"+": "plus",
|
|
12
|
+
"*": "asterisk"
|
|
13
|
+
};
|
|
14
|
+
const styleToMarker = {
|
|
15
|
+
"dash": "-",
|
|
16
|
+
"plus": "+",
|
|
17
|
+
"asterisk": "*"
|
|
18
|
+
};
|
|
19
|
+
const differentItemStyle = {
|
|
20
|
+
"dash": "plus",
|
|
21
|
+
"plus": "asterisk",
|
|
22
|
+
"asterisk": "dash"
|
|
23
|
+
};
|
|
24
|
+
const validStyles = new Set([
|
|
25
|
+
"asterisk",
|
|
26
|
+
"consistent",
|
|
27
|
+
"dash",
|
|
28
|
+
"plus",
|
|
29
|
+
"sublist"
|
|
30
|
+
]);
|
|
31
|
+
|
|
32
|
+
// eslint-disable-next-line jsdoc/valid-types
|
|
33
|
+
/** @type import("./markdownlint").Rule */
|
|
34
|
+
module.exports = {
|
|
35
|
+
"names": [ "MD004", "ul-style" ],
|
|
36
|
+
"description": "Unordered list style",
|
|
37
|
+
"tags": [ "bullet", "ul" ],
|
|
38
|
+
"parser": "micromark",
|
|
39
|
+
"function": function MD004(params, onError) {
|
|
40
|
+
const style = String(params.config.style || "consistent");
|
|
41
|
+
let expectedStyle = validStyles.has(style) ? style : "dash";
|
|
42
|
+
const nestingStyles = [];
|
|
43
|
+
for (const listUnordered of filterByTypesCached([ "listUnordered" ])) {
|
|
44
|
+
let nesting = 0;
|
|
45
|
+
if (style === "sublist") {
|
|
46
|
+
/** @type {import("../helpers/micromark.cjs").Token | null} */
|
|
47
|
+
let parent = listUnordered;
|
|
48
|
+
// @ts-ignore
|
|
49
|
+
while ((parent = getTokenParentOfType(parent, [ "listOrdered", "listUnordered" ]))) {
|
|
50
|
+
nesting++;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
const listItemMarkers = getDescendantsByType(listUnordered, [ "listItemPrefix", "listItemMarker" ]);
|
|
54
|
+
for (const listItemMarker of listItemMarkers) {
|
|
55
|
+
const itemStyle = markerToStyle[listItemMarker.text];
|
|
56
|
+
if (style === "sublist") {
|
|
57
|
+
if (!nestingStyles[nesting]) {
|
|
58
|
+
nestingStyles[nesting] =
|
|
59
|
+
(itemStyle === nestingStyles[nesting - 1]) ?
|
|
60
|
+
differentItemStyle[itemStyle] :
|
|
61
|
+
itemStyle;
|
|
62
|
+
}
|
|
63
|
+
expectedStyle = nestingStyles[nesting];
|
|
64
|
+
} else if (expectedStyle === "consistent") {
|
|
65
|
+
expectedStyle = itemStyle;
|
|
66
|
+
}
|
|
67
|
+
const column = listItemMarker.startColumn;
|
|
68
|
+
const length = listItemMarker.endColumn - listItemMarker.startColumn;
|
|
69
|
+
addErrorDetailIf(
|
|
70
|
+
onError,
|
|
71
|
+
listItemMarker.startLine,
|
|
72
|
+
expectedStyle,
|
|
73
|
+
itemStyle,
|
|
74
|
+
undefined,
|
|
75
|
+
undefined,
|
|
76
|
+
[ column, length ],
|
|
77
|
+
{
|
|
78
|
+
"editColumn": column,
|
|
79
|
+
"deleteCount": length,
|
|
80
|
+
"insertText": styleToMarker[expectedStyle]
|
|
81
|
+
}
|
|
82
|
+
);
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
};
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
// @ts-check
|
|
2
|
+
|
|
3
|
+
"use strict";
|
|
4
|
+
|
|
5
|
+
const { addError, addErrorDetailIf } = require("../helpers");
|
|
6
|
+
const { filterByTypesCached } = require("./cache");
|
|
7
|
+
|
|
8
|
+
// eslint-disable-next-line jsdoc/valid-types
|
|
9
|
+
/** @type import("./markdownlint").Rule */
|
|
10
|
+
module.exports = {
|
|
11
|
+
"names": [ "MD005", "list-indent" ],
|
|
12
|
+
"description": "Inconsistent indentation for list items at the same level",
|
|
13
|
+
"tags": [ "bullet", "ul", "indentation" ],
|
|
14
|
+
"parser": "micromark",
|
|
15
|
+
"function": function MD005(params, onError) {
|
|
16
|
+
for (const list of filterByTypesCached([ "listOrdered", "listUnordered" ])) {
|
|
17
|
+
const expectedIndent = list.startColumn - 1;
|
|
18
|
+
let expectedEnd = 0;
|
|
19
|
+
let endMatching = false;
|
|
20
|
+
const listItemPrefixes =
|
|
21
|
+
list.children.filter((token) => (token.type === "listItemPrefix"));
|
|
22
|
+
for (const listItemPrefix of listItemPrefixes) {
|
|
23
|
+
const lineNumber = listItemPrefix.startLine;
|
|
24
|
+
const actualIndent = listItemPrefix.startColumn - 1;
|
|
25
|
+
const range = [ 1, listItemPrefix.endColumn - 1 ];
|
|
26
|
+
if (list.type === "listUnordered") {
|
|
27
|
+
addErrorDetailIf(
|
|
28
|
+
onError,
|
|
29
|
+
lineNumber,
|
|
30
|
+
expectedIndent,
|
|
31
|
+
actualIndent,
|
|
32
|
+
undefined,
|
|
33
|
+
undefined,
|
|
34
|
+
range
|
|
35
|
+
// No fixInfo; MD007 handles this scenario better
|
|
36
|
+
);
|
|
37
|
+
} else {
|
|
38
|
+
const markerLength = listItemPrefix.text.trim().length;
|
|
39
|
+
const actualEnd = listItemPrefix.startColumn + markerLength - 1;
|
|
40
|
+
expectedEnd = expectedEnd || actualEnd;
|
|
41
|
+
if ((expectedIndent !== actualIndent) || endMatching) {
|
|
42
|
+
if (expectedEnd === actualEnd) {
|
|
43
|
+
endMatching = true;
|
|
44
|
+
} else {
|
|
45
|
+
const detail = endMatching ?
|
|
46
|
+
`Expected: (${expectedEnd}); Actual: (${actualEnd})` :
|
|
47
|
+
`Expected: ${expectedIndent}; Actual: ${actualIndent}`;
|
|
48
|
+
const expected = endMatching ?
|
|
49
|
+
expectedEnd - markerLength :
|
|
50
|
+
expectedIndent;
|
|
51
|
+
const actual = endMatching ?
|
|
52
|
+
actualEnd - markerLength :
|
|
53
|
+
actualIndent;
|
|
54
|
+
addError(
|
|
55
|
+
onError,
|
|
56
|
+
lineNumber,
|
|
57
|
+
detail,
|
|
58
|
+
undefined,
|
|
59
|
+
range,
|
|
60
|
+
{
|
|
61
|
+
"editColumn": Math.min(actual, expected) + 1,
|
|
62
|
+
"deleteCount": Math.max(actual - expected, 0),
|
|
63
|
+
"insertText": "".padEnd(Math.max(expected - actual, 0))
|
|
64
|
+
}
|
|
65
|
+
);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
};
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
// @ts-check
|
|
2
|
+
|
|
3
|
+
"use strict";
|
|
4
|
+
|
|
5
|
+
const { addErrorDetailIf } = require("../helpers");
|
|
6
|
+
const { getTokenParentOfType } = require("../helpers/micromark.cjs");
|
|
7
|
+
const { filterByTypesCached } = require("./cache");
|
|
8
|
+
|
|
9
|
+
// eslint-disable-next-line jsdoc/valid-types
|
|
10
|
+
/** @type import("markdownlint-micromark").TokenType[] */
|
|
11
|
+
const unorderedListTypes =
|
|
12
|
+
[ "blockQuotePrefix", "listItemPrefix", "listUnordered" ];
|
|
13
|
+
// eslint-disable-next-line jsdoc/valid-types
|
|
14
|
+
/** @type import("markdownlint-micromark").TokenType[] */
|
|
15
|
+
const unorderedParentTypes =
|
|
16
|
+
[ "blockQuote", "listOrdered", "listUnordered" ];
|
|
17
|
+
|
|
18
|
+
// eslint-disable-next-line jsdoc/valid-types
|
|
19
|
+
/** @type import("./markdownlint").Rule */
|
|
20
|
+
module.exports = {
|
|
21
|
+
"names": [ "MD007", "ul-indent" ],
|
|
22
|
+
"description": "Unordered list indentation",
|
|
23
|
+
"tags": [ "bullet", "ul", "indentation" ],
|
|
24
|
+
"parser": "micromark",
|
|
25
|
+
"function": function MD007(params, onError) {
|
|
26
|
+
const indent = Number(params.config.indent || 2);
|
|
27
|
+
const startIndented = !!params.config.start_indented;
|
|
28
|
+
const startIndent = Number(params.config.start_indent || indent);
|
|
29
|
+
const unorderedListNesting = new Map();
|
|
30
|
+
let lastBlockQuotePrefix = null;
|
|
31
|
+
const tokens = filterByTypesCached(unorderedListTypes);
|
|
32
|
+
for (const token of tokens) {
|
|
33
|
+
const { endColumn, parent, startColumn, startLine, type } = token;
|
|
34
|
+
if (type === "blockQuotePrefix") {
|
|
35
|
+
lastBlockQuotePrefix = token;
|
|
36
|
+
} else if (type === "listUnordered") {
|
|
37
|
+
let nesting = 0;
|
|
38
|
+
/** @type {import("../helpers/micromark.cjs").Token | null} */
|
|
39
|
+
let current = token;
|
|
40
|
+
while (
|
|
41
|
+
// @ts-ignore
|
|
42
|
+
(current = getTokenParentOfType(current, unorderedParentTypes))
|
|
43
|
+
) {
|
|
44
|
+
if (current.type === "listUnordered") {
|
|
45
|
+
nesting++;
|
|
46
|
+
// eslint-disable-next-line no-continue
|
|
47
|
+
continue;
|
|
48
|
+
} else if (current.type === "listOrdered") {
|
|
49
|
+
nesting = -1;
|
|
50
|
+
}
|
|
51
|
+
break;
|
|
52
|
+
}
|
|
53
|
+
if (nesting >= 0) {
|
|
54
|
+
unorderedListNesting.set(token, nesting);
|
|
55
|
+
}
|
|
56
|
+
} else {
|
|
57
|
+
// listItemPrefix
|
|
58
|
+
const nesting = unorderedListNesting.get(parent);
|
|
59
|
+
if (nesting !== undefined) {
|
|
60
|
+
// listItemPrefix for listUnordered
|
|
61
|
+
const expectedIndent =
|
|
62
|
+
(startIndented ? startIndent : 0) + (nesting * indent);
|
|
63
|
+
const blockQuoteAdjustment =
|
|
64
|
+
(lastBlockQuotePrefix?.endLine === startLine) ?
|
|
65
|
+
(lastBlockQuotePrefix.endColumn - 1) :
|
|
66
|
+
0;
|
|
67
|
+
const actualIndent = startColumn - 1 - blockQuoteAdjustment;
|
|
68
|
+
const range = [ 1, endColumn - 1 ];
|
|
69
|
+
const fixInfo = {
|
|
70
|
+
"editColumn": startColumn - actualIndent,
|
|
71
|
+
"deleteCount": Math.max(actualIndent - expectedIndent, 0),
|
|
72
|
+
"insertText": "".padEnd(Math.max(expectedIndent - actualIndent, 0))
|
|
73
|
+
};
|
|
74
|
+
addErrorDetailIf(
|
|
75
|
+
onError,
|
|
76
|
+
startLine,
|
|
77
|
+
expectedIndent,
|
|
78
|
+
actualIndent,
|
|
79
|
+
undefined,
|
|
80
|
+
undefined,
|
|
81
|
+
range,
|
|
82
|
+
fixInfo
|
|
83
|
+
);
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
};
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
// @ts-check
|
|
2
|
+
|
|
3
|
+
"use strict";
|
|
4
|
+
|
|
5
|
+
const { addError } = require("../helpers");
|
|
6
|
+
const { addRangeToSet } = require("../helpers/micromark.cjs");
|
|
7
|
+
const { filterByTypesCached } = require("./cache");
|
|
8
|
+
|
|
9
|
+
// eslint-disable-next-line jsdoc/valid-types
|
|
10
|
+
/** @type import("./markdownlint").Rule */
|
|
11
|
+
module.exports = {
|
|
12
|
+
"names": [ "MD009", "no-trailing-spaces" ],
|
|
13
|
+
"description": "Trailing spaces",
|
|
14
|
+
"tags": [ "whitespace" ],
|
|
15
|
+
"parser": "micromark",
|
|
16
|
+
"function": function MD009(params, onError) {
|
|
17
|
+
let brSpaces = params.config.br_spaces;
|
|
18
|
+
brSpaces = Number((brSpaces === undefined) ? 2 : brSpaces);
|
|
19
|
+
const listItemEmptyLines = !!params.config.list_item_empty_lines;
|
|
20
|
+
const strict = !!params.config.strict;
|
|
21
|
+
const codeBlockLineNumbers = new Set();
|
|
22
|
+
for (const codeBlock of filterByTypesCached([ "codeFenced" ])) {
|
|
23
|
+
addRangeToSet(codeBlockLineNumbers, codeBlock.startLine + 1, codeBlock.endLine - 1);
|
|
24
|
+
}
|
|
25
|
+
for (const codeBlock of filterByTypesCached([ "codeIndented" ])) {
|
|
26
|
+
addRangeToSet(codeBlockLineNumbers, codeBlock.startLine, codeBlock.endLine);
|
|
27
|
+
}
|
|
28
|
+
const listItemLineNumbers = new Set();
|
|
29
|
+
if (listItemEmptyLines) {
|
|
30
|
+
for (const listBlock of filterByTypesCached([ "listOrdered", "listUnordered" ])) {
|
|
31
|
+
addRangeToSet(listItemLineNumbers, listBlock.startLine, listBlock.endLine);
|
|
32
|
+
let trailingIndent = true;
|
|
33
|
+
for (let i = listBlock.children.length - 1; i >= 0; i--) {
|
|
34
|
+
const child = listBlock.children[i];
|
|
35
|
+
switch (child.type) {
|
|
36
|
+
case "content":
|
|
37
|
+
trailingIndent = false;
|
|
38
|
+
break;
|
|
39
|
+
case "listItemIndent":
|
|
40
|
+
if (trailingIndent) {
|
|
41
|
+
listItemLineNumbers.delete(child.startLine);
|
|
42
|
+
}
|
|
43
|
+
break;
|
|
44
|
+
case "listItemPrefix":
|
|
45
|
+
trailingIndent = true;
|
|
46
|
+
break;
|
|
47
|
+
default:
|
|
48
|
+
break;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
const paragraphLineNumbers = new Set();
|
|
54
|
+
const codeInlineLineNumbers = new Set();
|
|
55
|
+
if (strict) {
|
|
56
|
+
for (const paragraph of filterByTypesCached([ "paragraph" ])) {
|
|
57
|
+
addRangeToSet(paragraphLineNumbers, paragraph.startLine, paragraph.endLine - 1);
|
|
58
|
+
}
|
|
59
|
+
for (const codeText of filterByTypesCached([ "codeText" ])) {
|
|
60
|
+
addRangeToSet(codeInlineLineNumbers, codeText.startLine, codeText.endLine - 1);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
const expected = (brSpaces < 2) ? 0 : brSpaces;
|
|
64
|
+
for (let lineIndex = 0; lineIndex < params.lines.length; lineIndex++) {
|
|
65
|
+
const line = params.lines[lineIndex];
|
|
66
|
+
const lineNumber = lineIndex + 1;
|
|
67
|
+
const trailingSpaces = line.length - line.trimEnd().length;
|
|
68
|
+
if (
|
|
69
|
+
trailingSpaces &&
|
|
70
|
+
!codeBlockLineNumbers.has(lineNumber) &&
|
|
71
|
+
!listItemLineNumbers.has(lineNumber) &&
|
|
72
|
+
(
|
|
73
|
+
(expected !== trailingSpaces) ||
|
|
74
|
+
(strict &&
|
|
75
|
+
(!paragraphLineNumbers.has(lineNumber) ||
|
|
76
|
+
codeInlineLineNumbers.has(lineNumber)))
|
|
77
|
+
)
|
|
78
|
+
) {
|
|
79
|
+
const column = line.length - trailingSpaces + 1;
|
|
80
|
+
addError(
|
|
81
|
+
onError,
|
|
82
|
+
lineNumber,
|
|
83
|
+
"Expected: " + (expected === 0 ? "" : "0 or ") +
|
|
84
|
+
expected + "; Actual: " + trailingSpaces,
|
|
85
|
+
undefined,
|
|
86
|
+
[ column, trailingSpaces ],
|
|
87
|
+
{
|
|
88
|
+
"editColumn": column,
|
|
89
|
+
"deleteCount": trailingSpaces
|
|
90
|
+
}
|
|
91
|
+
);
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
};
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
// @ts-check
|
|
2
|
+
|
|
3
|
+
"use strict";
|
|
4
|
+
|
|
5
|
+
const { addError, withinAnyRange } = require("../helpers");
|
|
6
|
+
const { getDescendantsByType, getExclusionsForToken } = require("../helpers/micromark.cjs");
|
|
7
|
+
const { filterByTypesCached } = require("./cache");
|
|
8
|
+
|
|
9
|
+
const tabRe = /\t+/g;
|
|
10
|
+
|
|
11
|
+
// eslint-disable-next-line jsdoc/valid-types
|
|
12
|
+
/** @type import("./markdownlint").Rule */
|
|
13
|
+
module.exports = {
|
|
14
|
+
"names": [ "MD010", "no-hard-tabs" ],
|
|
15
|
+
"description": "Hard tabs",
|
|
16
|
+
"tags": [ "whitespace", "hard_tab" ],
|
|
17
|
+
"parser": "micromark",
|
|
18
|
+
"function": function MD010(params, onError) {
|
|
19
|
+
const codeBlocks = params.config.code_blocks;
|
|
20
|
+
const includeCode = (codeBlocks === undefined) ? true : !!codeBlocks;
|
|
21
|
+
const ignoreCodeLanguages = new Set(
|
|
22
|
+
(params.config.ignore_code_languages || [])
|
|
23
|
+
.map((language) => language.toLowerCase())
|
|
24
|
+
);
|
|
25
|
+
const spacesPerTab = params.config.spaces_per_tab;
|
|
26
|
+
const spaceMultiplier = (spacesPerTab === undefined) ?
|
|
27
|
+
1 :
|
|
28
|
+
Math.max(0, Number(spacesPerTab));
|
|
29
|
+
const exclusions = [];
|
|
30
|
+
// eslint-disable-next-line jsdoc/valid-types
|
|
31
|
+
/** @type import("../helpers/micromark.cjs").TokenType[] */
|
|
32
|
+
const exclusionTypes = [];
|
|
33
|
+
if (includeCode) {
|
|
34
|
+
if (ignoreCodeLanguages.size > 0) {
|
|
35
|
+
exclusionTypes.push("codeFenced");
|
|
36
|
+
}
|
|
37
|
+
} else {
|
|
38
|
+
exclusionTypes.push("codeFenced", "codeIndented", "codeText");
|
|
39
|
+
}
|
|
40
|
+
const codeTokens = filterByTypesCached(exclusionTypes).filter((token) => {
|
|
41
|
+
if ((token.type === "codeFenced") && (ignoreCodeLanguages.size > 0)) {
|
|
42
|
+
const fenceInfos = getDescendantsByType(token, [ "codeFencedFence", "codeFencedFenceInfo" ]);
|
|
43
|
+
return fenceInfos.every((fenceInfo) => ignoreCodeLanguages.has(fenceInfo.text.toLowerCase()));
|
|
44
|
+
}
|
|
45
|
+
return true;
|
|
46
|
+
});
|
|
47
|
+
for (const codeToken of codeTokens) {
|
|
48
|
+
const exclusionsForToken = getExclusionsForToken(params.lines, codeToken);
|
|
49
|
+
if (codeToken.type === "codeFenced") {
|
|
50
|
+
exclusionsForToken.pop();
|
|
51
|
+
exclusionsForToken.shift();
|
|
52
|
+
}
|
|
53
|
+
exclusions.push(...exclusionsForToken);
|
|
54
|
+
}
|
|
55
|
+
for (let lineIndex = 0; lineIndex < params.lines.length; lineIndex++) {
|
|
56
|
+
const line = params.lines[lineIndex];
|
|
57
|
+
let match = null;
|
|
58
|
+
while ((match = tabRe.exec(line)) !== null) {
|
|
59
|
+
const column = match.index + 1;
|
|
60
|
+
const length = match[0].length;
|
|
61
|
+
if (!withinAnyRange(exclusions, lineIndex + 1, column, length)) {
|
|
62
|
+
addError(
|
|
63
|
+
onError,
|
|
64
|
+
lineIndex + 1,
|
|
65
|
+
"Column: " + column,
|
|
66
|
+
undefined,
|
|
67
|
+
[ column, length ],
|
|
68
|
+
{
|
|
69
|
+
"editColumn": column,
|
|
70
|
+
"deleteCount": length,
|
|
71
|
+
"insertText": "".padEnd(length * spaceMultiplier)
|
|
72
|
+
}
|
|
73
|
+
);
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
};
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
// @ts-check
|
|
2
|
+
|
|
3
|
+
"use strict";
|
|
4
|
+
|
|
5
|
+
const { addError, withinAnyRange } = require("../helpers");
|
|
6
|
+
const { addRangeToSet, getExclusionsForToken } = require("../helpers/micromark.cjs");
|
|
7
|
+
const { filterByTypesCached } = require("./cache");
|
|
8
|
+
|
|
9
|
+
const reversedLinkRe =
|
|
10
|
+
/(^|[^\\])\(([^()]+)\)\[([^\]^][^\]]*)\](?!\()/g;
|
|
11
|
+
|
|
12
|
+
// eslint-disable-next-line jsdoc/valid-types
|
|
13
|
+
/** @type import("./markdownlint").Rule */
|
|
14
|
+
module.exports = {
|
|
15
|
+
"names": [ "MD011", "no-reversed-links" ],
|
|
16
|
+
"description": "Reversed link syntax",
|
|
17
|
+
"tags": [ "links" ],
|
|
18
|
+
"parser": "micromark",
|
|
19
|
+
"function": function MD011(params, onError) {
|
|
20
|
+
const codeBlockLineNumbers = new Set();
|
|
21
|
+
for (const codeBlock of filterByTypesCached([ "codeFenced", "codeIndented" ])) {
|
|
22
|
+
addRangeToSet(codeBlockLineNumbers, codeBlock.startLine, codeBlock.endLine);
|
|
23
|
+
}
|
|
24
|
+
const exclusions = [];
|
|
25
|
+
for (const codeText of filterByTypesCached([ "codeText" ])) {
|
|
26
|
+
exclusions.push(...getExclusionsForToken(params.lines, codeText));
|
|
27
|
+
}
|
|
28
|
+
for (const [ lineIndex, line ] of params.lines.entries()) {
|
|
29
|
+
if (!codeBlockLineNumbers.has(lineIndex + 1)) {
|
|
30
|
+
let match = null;
|
|
31
|
+
while ((match = reversedLinkRe.exec(line)) !== null) {
|
|
32
|
+
const [ reversedLink, preChar, linkText, linkDestination ] = match;
|
|
33
|
+
const index = match.index + preChar.length;
|
|
34
|
+
const length = match[0].length - preChar.length;
|
|
35
|
+
if (
|
|
36
|
+
!linkText.endsWith("\\") &&
|
|
37
|
+
!linkDestination.endsWith("\\") &&
|
|
38
|
+
!withinAnyRange(exclusions, lineIndex + 1, index, length)
|
|
39
|
+
) {
|
|
40
|
+
addError(
|
|
41
|
+
onError,
|
|
42
|
+
lineIndex + 1,
|
|
43
|
+
reversedLink.slice(preChar.length),
|
|
44
|
+
undefined,
|
|
45
|
+
[ index + 1, length ],
|
|
46
|
+
{
|
|
47
|
+
"editColumn": index + 1,
|
|
48
|
+
"deleteCount": length,
|
|
49
|
+
"insertText": `[${linkText}](${linkDestination})`
|
|
50
|
+
}
|
|
51
|
+
);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
};
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
// @ts-check
|
|
2
|
+
|
|
3
|
+
"use strict";
|
|
4
|
+
|
|
5
|
+
const { addErrorDetailIf } = require("../helpers");
|
|
6
|
+
const { addRangeToSet } = require("../helpers/micromark.cjs");
|
|
7
|
+
const { filterByTypesCached } = require("./cache");
|
|
8
|
+
|
|
9
|
+
// eslint-disable-next-line jsdoc/valid-types
|
|
10
|
+
/** @type import("./markdownlint").Rule */
|
|
11
|
+
module.exports = {
|
|
12
|
+
"names": [ "MD012", "no-multiple-blanks" ],
|
|
13
|
+
"description": "Multiple consecutive blank lines",
|
|
14
|
+
"tags": [ "whitespace", "blank_lines" ],
|
|
15
|
+
"parser": "micromark",
|
|
16
|
+
"function": function MD012(params, onError) {
|
|
17
|
+
const maximum = Number(params.config.maximum || 1);
|
|
18
|
+
const { lines } = params;
|
|
19
|
+
const codeBlockLineNumbers = new Set();
|
|
20
|
+
for (const codeBlock of filterByTypesCached([ "codeFenced", "codeIndented" ])) {
|
|
21
|
+
addRangeToSet(codeBlockLineNumbers, codeBlock.startLine, codeBlock.endLine);
|
|
22
|
+
}
|
|
23
|
+
let count = 0;
|
|
24
|
+
for (const [ lineIndex, line ] of lines.entries()) {
|
|
25
|
+
const inCode = codeBlockLineNumbers.has(lineIndex + 1);
|
|
26
|
+
count = (inCode || (line.trim().length > 0)) ? 0 : count + 1;
|
|
27
|
+
if (maximum < count) {
|
|
28
|
+
addErrorDetailIf(
|
|
29
|
+
onError,
|
|
30
|
+
lineIndex + 1,
|
|
31
|
+
maximum,
|
|
32
|
+
count,
|
|
33
|
+
undefined,
|
|
34
|
+
undefined,
|
|
35
|
+
undefined,
|
|
36
|
+
{
|
|
37
|
+
"deleteCount": -1
|
|
38
|
+
}
|
|
39
|
+
);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
};
|