@alexlit/lint-kit 127.1.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-commitlint/package.json +3 -3
- package/packages/config-eslint/package.json +2 -2
- 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
- package/packages/config-stylelint/package.json +2 -2
- package/packages/config-stylelint/plugins/scss.js +1 -0
- package/scripts/up.sh +6 -2
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
// @ts-check
|
|
2
|
+
|
|
3
|
+
"use strict";
|
|
4
|
+
|
|
5
|
+
const { addError } = require("../helpers");
|
|
6
|
+
const { filterByTypesCached } = require("./cache");
|
|
7
|
+
|
|
8
|
+
const ignoreTypes = new Set([ "lineEnding", "listItemIndent", "linePrefix" ]);
|
|
9
|
+
|
|
10
|
+
// eslint-disable-next-line jsdoc/valid-types
|
|
11
|
+
/** @type import("./markdownlint").Rule */
|
|
12
|
+
module.exports = {
|
|
13
|
+
"names": [ "MD028", "no-blanks-blockquote" ],
|
|
14
|
+
"description": "Blank line inside blockquote",
|
|
15
|
+
"tags": [ "blockquote", "whitespace" ],
|
|
16
|
+
"parser": "micromark",
|
|
17
|
+
"function": function MD028(params, onError) {
|
|
18
|
+
for (const token of filterByTypesCached([ "blockQuote" ])) {
|
|
19
|
+
const errorLineNumbers = [];
|
|
20
|
+
const siblings = token.parent?.children || params.parsers.micromark.tokens;
|
|
21
|
+
for (let i = siblings.indexOf(token) + 1; i < siblings.length; i++) {
|
|
22
|
+
const sibling = siblings[i];
|
|
23
|
+
const { startLine, type } = sibling;
|
|
24
|
+
if (type === "lineEndingBlank") {
|
|
25
|
+
// Possible blank between blockquotes
|
|
26
|
+
errorLineNumbers.push(startLine);
|
|
27
|
+
} else if (ignoreTypes.has(type)) {
|
|
28
|
+
// Ignore invisible formatting
|
|
29
|
+
} else if (type === "blockQuote") {
|
|
30
|
+
// Blockquote followed by blockquote
|
|
31
|
+
for (const lineNumber of errorLineNumbers) {
|
|
32
|
+
addError(onError, lineNumber);
|
|
33
|
+
}
|
|
34
|
+
break;
|
|
35
|
+
} else {
|
|
36
|
+
// Blockquote not followed by blockquote
|
|
37
|
+
break;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
};
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
// @ts-check
|
|
2
|
+
|
|
3
|
+
"use strict";
|
|
4
|
+
|
|
5
|
+
const { addErrorDetailIf } = require("../helpers");
|
|
6
|
+
const { getDescendantsByType, getTokenTextByType } = require("../helpers/micromark.cjs");
|
|
7
|
+
const { filterByTypesCached } = require("./cache");
|
|
8
|
+
|
|
9
|
+
const listStyleExamples = {
|
|
10
|
+
"one": "1/1/1",
|
|
11
|
+
"ordered": "1/2/3",
|
|
12
|
+
"zero": "0/0/0"
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Gets the value of an ordered list item prefix token.
|
|
17
|
+
*
|
|
18
|
+
* @param {import("../helpers/micromark.cjs").Token} listItemPrefix List item prefix token.
|
|
19
|
+
* @returns {number} List item value.
|
|
20
|
+
*/
|
|
21
|
+
function getOrderedListItemValue(listItemPrefix) {
|
|
22
|
+
return Number(getTokenTextByType(listItemPrefix.children, "listItemValue"));
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
// eslint-disable-next-line jsdoc/valid-types
|
|
26
|
+
/** @type import("./markdownlint").Rule */
|
|
27
|
+
module.exports = {
|
|
28
|
+
"names": [ "MD029", "ol-prefix" ],
|
|
29
|
+
"description": "Ordered list item prefix",
|
|
30
|
+
"tags": [ "ol" ],
|
|
31
|
+
"parser": "micromark",
|
|
32
|
+
"function": function MD029(params, onError) {
|
|
33
|
+
const style = String(params.config.style || "one_or_ordered");
|
|
34
|
+
for (const listOrdered of filterByTypesCached([ "listOrdered" ])) {
|
|
35
|
+
const listItemPrefixes = getDescendantsByType(listOrdered, [ "listItemPrefix" ]);
|
|
36
|
+
let expected = 1;
|
|
37
|
+
let incrementing = false;
|
|
38
|
+
// Check for incrementing number pattern 1/2/3 or 0/1/2
|
|
39
|
+
if (listItemPrefixes.length >= 2) {
|
|
40
|
+
const firstValue = getOrderedListItemValue(listItemPrefixes[0]);
|
|
41
|
+
const secondValue = getOrderedListItemValue(listItemPrefixes[1]);
|
|
42
|
+
if ((secondValue !== 1) || (firstValue === 0)) {
|
|
43
|
+
incrementing = true;
|
|
44
|
+
if (firstValue === 0) {
|
|
45
|
+
expected = 0;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
// Determine effective style
|
|
50
|
+
let listStyle = style;
|
|
51
|
+
if (listStyle === "one_or_ordered") {
|
|
52
|
+
listStyle = incrementing ? "ordered" : "one";
|
|
53
|
+
} else if (listStyle === "zero") {
|
|
54
|
+
expected = 0;
|
|
55
|
+
} else if (listStyle === "one") {
|
|
56
|
+
expected = 1;
|
|
57
|
+
}
|
|
58
|
+
// Validate each list item marker
|
|
59
|
+
for (const listItemPrefix of listItemPrefixes) {
|
|
60
|
+
const actual = getOrderedListItemValue(listItemPrefix);
|
|
61
|
+
addErrorDetailIf(
|
|
62
|
+
onError,
|
|
63
|
+
listItemPrefix.startLine,
|
|
64
|
+
expected,
|
|
65
|
+
actual,
|
|
66
|
+
"Style: " + listStyleExamples[listStyle],
|
|
67
|
+
undefined,
|
|
68
|
+
[ listItemPrefix.startColumn, listItemPrefix.endColumn - listItemPrefix.startColumn ]
|
|
69
|
+
);
|
|
70
|
+
if (listStyle === "ordered") {
|
|
71
|
+
expected++;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
};
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
// @ts-check
|
|
2
|
+
|
|
3
|
+
"use strict";
|
|
4
|
+
|
|
5
|
+
const { 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": [ "MD030", "list-marker-space" ],
|
|
12
|
+
"description": "Spaces after list markers",
|
|
13
|
+
"tags": [ "ol", "ul", "whitespace" ],
|
|
14
|
+
"parser": "micromark",
|
|
15
|
+
"function": function MD030(params, onError) {
|
|
16
|
+
const ulSingle = Number(params.config.ul_single || 1);
|
|
17
|
+
const olSingle = Number(params.config.ol_single || 1);
|
|
18
|
+
const ulMulti = Number(params.config.ul_multi || 1);
|
|
19
|
+
const olMulti = Number(params.config.ol_multi || 1);
|
|
20
|
+
for (const list of filterByTypesCached([ "listOrdered", "listUnordered" ])) {
|
|
21
|
+
const ordered = (list.type === "listOrdered");
|
|
22
|
+
const listItemPrefixes =
|
|
23
|
+
list.children.filter((token) => (token.type === "listItemPrefix"));
|
|
24
|
+
const allSingleLine =
|
|
25
|
+
(list.endLine - list.startLine + 1) === listItemPrefixes.length;
|
|
26
|
+
const expectedSpaces = ordered ?
|
|
27
|
+
(allSingleLine ? olSingle : olMulti) :
|
|
28
|
+
(allSingleLine ? ulSingle : ulMulti);
|
|
29
|
+
for (const listItemPrefix of listItemPrefixes) {
|
|
30
|
+
const range = [
|
|
31
|
+
listItemPrefix.startColumn,
|
|
32
|
+
listItemPrefix.endColumn - listItemPrefix.startColumn
|
|
33
|
+
];
|
|
34
|
+
const listItemPrefixWhitespaces = listItemPrefix.children.filter(
|
|
35
|
+
(token) => (token.type === "listItemPrefixWhitespace")
|
|
36
|
+
);
|
|
37
|
+
for (const listItemPrefixWhitespace of listItemPrefixWhitespaces) {
|
|
38
|
+
const { endColumn, startColumn, startLine } =
|
|
39
|
+
listItemPrefixWhitespace;
|
|
40
|
+
const actualSpaces = endColumn - startColumn;
|
|
41
|
+
const fixInfo = {
|
|
42
|
+
"editColumn": startColumn,
|
|
43
|
+
"deleteCount": actualSpaces,
|
|
44
|
+
"insertText": "".padEnd(expectedSpaces)
|
|
45
|
+
};
|
|
46
|
+
addErrorDetailIf(
|
|
47
|
+
onError,
|
|
48
|
+
startLine,
|
|
49
|
+
expectedSpaces,
|
|
50
|
+
actualSpaces,
|
|
51
|
+
undefined,
|
|
52
|
+
undefined,
|
|
53
|
+
range,
|
|
54
|
+
fixInfo
|
|
55
|
+
);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
};
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
// @ts-check
|
|
2
|
+
|
|
3
|
+
"use strict";
|
|
4
|
+
|
|
5
|
+
const { addErrorContext, isBlankLine } = require("../helpers");
|
|
6
|
+
const { getTokenParentOfType } = require("../helpers/micromark.cjs");
|
|
7
|
+
const { filterByTypesCached } = require("./cache");
|
|
8
|
+
|
|
9
|
+
const codeFencePrefixRe = /^(.*?)[`~]/;
|
|
10
|
+
|
|
11
|
+
// eslint-disable-next-line jsdoc/valid-types
|
|
12
|
+
/** @typedef {readonly string[]} ReadonlyStringArray */
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Adds an error for the top or bottom of a code fence.
|
|
16
|
+
*
|
|
17
|
+
* @param {import("./markdownlint").RuleOnError} onError Error-reporting callback.
|
|
18
|
+
* @param {ReadonlyStringArray} lines Lines of Markdown content.
|
|
19
|
+
* @param {number} lineNumber Line number.
|
|
20
|
+
* @param {boolean} top True iff top fence.
|
|
21
|
+
* @returns {void}
|
|
22
|
+
*/
|
|
23
|
+
function addError(onError, lines, lineNumber, top) {
|
|
24
|
+
const line = lines[lineNumber - 1];
|
|
25
|
+
const [ , prefix ] = line.match(codeFencePrefixRe) || [];
|
|
26
|
+
const fixInfo = (prefix === undefined) ? null : {
|
|
27
|
+
"lineNumber": lineNumber + (top ? 0 : 1),
|
|
28
|
+
"insertText": `${prefix.replace(/[^>]/g, " ").trim()}\n`
|
|
29
|
+
};
|
|
30
|
+
addErrorContext(
|
|
31
|
+
onError,
|
|
32
|
+
lineNumber,
|
|
33
|
+
line.trim(),
|
|
34
|
+
undefined,
|
|
35
|
+
undefined,
|
|
36
|
+
undefined,
|
|
37
|
+
fixInfo
|
|
38
|
+
);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
// eslint-disable-next-line jsdoc/valid-types
|
|
42
|
+
/** @type import("./markdownlint").Rule */
|
|
43
|
+
module.exports = {
|
|
44
|
+
"names": [ "MD031", "blanks-around-fences" ],
|
|
45
|
+
"description": "Fenced code blocks should be surrounded by blank lines",
|
|
46
|
+
"tags": [ "code", "blank_lines" ],
|
|
47
|
+
"parser": "micromark",
|
|
48
|
+
"function": function MD031(params, onError) {
|
|
49
|
+
const listItems = params.config.list_items;
|
|
50
|
+
const includeListItems = (listItems === undefined) ? true : !!listItems;
|
|
51
|
+
const { lines } = params;
|
|
52
|
+
for (const codeBlock of filterByTypesCached([ "codeFenced" ])) {
|
|
53
|
+
if (includeListItems || !(getTokenParentOfType(codeBlock, [ "listOrdered", "listUnordered" ]))) {
|
|
54
|
+
if (!isBlankLine(lines[codeBlock.startLine - 2])) {
|
|
55
|
+
addError(onError, lines, codeBlock.startLine, true);
|
|
56
|
+
}
|
|
57
|
+
if (!isBlankLine(lines[codeBlock.endLine]) && !isBlankLine(lines[codeBlock.endLine - 1])) {
|
|
58
|
+
addError(onError, lines, codeBlock.endLine, false);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
};
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
// @ts-check
|
|
2
|
+
|
|
3
|
+
"use strict";
|
|
4
|
+
|
|
5
|
+
const { addErrorContextForLine, isBlankLine } = require("../helpers");
|
|
6
|
+
const { filterByPredicate, nonContentTokens } = require("../helpers/micromark.cjs");
|
|
7
|
+
|
|
8
|
+
const isList = (token) => (
|
|
9
|
+
(token.type === "listOrdered") || (token.type === "listUnordered")
|
|
10
|
+
);
|
|
11
|
+
|
|
12
|
+
// eslint-disable-next-line jsdoc/valid-types
|
|
13
|
+
/** @type import("./markdownlint").Rule */
|
|
14
|
+
module.exports = {
|
|
15
|
+
"names": [ "MD032", "blanks-around-lists" ],
|
|
16
|
+
"description": "Lists should be surrounded by blank lines",
|
|
17
|
+
"tags": [ "bullet", "ul", "ol", "blank_lines" ],
|
|
18
|
+
"parser": "micromark",
|
|
19
|
+
"function": function MD032(params, onError) {
|
|
20
|
+
const { lines, parsers } = params;
|
|
21
|
+
|
|
22
|
+
// For every top-level list...
|
|
23
|
+
const topLevelLists = filterByPredicate(
|
|
24
|
+
parsers.micromark.tokens,
|
|
25
|
+
isList,
|
|
26
|
+
(token) => (
|
|
27
|
+
(isList(token) || (token.type === "htmlFlow")) ? [] : token.children
|
|
28
|
+
)
|
|
29
|
+
);
|
|
30
|
+
for (const list of topLevelLists) {
|
|
31
|
+
|
|
32
|
+
// Look for a blank line above the list
|
|
33
|
+
const firstIndex = list.startLine - 1;
|
|
34
|
+
if (!isBlankLine(lines[firstIndex - 1])) {
|
|
35
|
+
addErrorContextForLine(
|
|
36
|
+
onError,
|
|
37
|
+
// @ts-ignore
|
|
38
|
+
lines,
|
|
39
|
+
firstIndex
|
|
40
|
+
);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
// Find the "visual" end of the list
|
|
44
|
+
let endLine = list.endLine;
|
|
45
|
+
const flattenedChildren = filterByPredicate(list.children);
|
|
46
|
+
for (const child of flattenedChildren.reverse()) {
|
|
47
|
+
if (!nonContentTokens.has(child.type)) {
|
|
48
|
+
endLine = child.endLine;
|
|
49
|
+
break;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
// Look for a blank line below the list
|
|
54
|
+
const lastIndex = endLine - 1;
|
|
55
|
+
if (!isBlankLine(lines[lastIndex + 1])) {
|
|
56
|
+
addErrorContextForLine(
|
|
57
|
+
onError,
|
|
58
|
+
// @ts-ignore
|
|
59
|
+
lines,
|
|
60
|
+
lastIndex,
|
|
61
|
+
lastIndex + 2
|
|
62
|
+
);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
};
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
// @ts-check
|
|
2
|
+
|
|
3
|
+
"use strict";
|
|
4
|
+
|
|
5
|
+
const { addError, nextLinesRe } = require("../helpers");
|
|
6
|
+
const { getHtmlTagInfo } = 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": [ "MD033", "no-inline-html" ],
|
|
13
|
+
"description": "Inline HTML",
|
|
14
|
+
"tags": [ "html" ],
|
|
15
|
+
"parser": "micromark",
|
|
16
|
+
"function": function MD033(params, onError) {
|
|
17
|
+
let allowedElements = params.config.allowed_elements;
|
|
18
|
+
allowedElements = Array.isArray(allowedElements) ? allowedElements : [];
|
|
19
|
+
allowedElements = allowedElements.map((element) => element.toLowerCase());
|
|
20
|
+
for (const token of filterByTypesCached([ "htmlText" ], true)) {
|
|
21
|
+
const htmlTagInfo = getHtmlTagInfo(token);
|
|
22
|
+
if (
|
|
23
|
+
htmlTagInfo &&
|
|
24
|
+
!htmlTagInfo.close &&
|
|
25
|
+
!allowedElements.includes(htmlTagInfo.name.toLowerCase())
|
|
26
|
+
) {
|
|
27
|
+
const range = [
|
|
28
|
+
token.startColumn,
|
|
29
|
+
token.text.replace(nextLinesRe, "").length
|
|
30
|
+
];
|
|
31
|
+
addError(
|
|
32
|
+
onError,
|
|
33
|
+
token.startLine,
|
|
34
|
+
"Element: " + htmlTagInfo.name,
|
|
35
|
+
undefined,
|
|
36
|
+
range
|
|
37
|
+
);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
};
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
// @ts-check
|
|
2
|
+
|
|
3
|
+
"use strict";
|
|
4
|
+
|
|
5
|
+
const { addErrorContext } = require("../helpers");
|
|
6
|
+
const { filterByPredicate, getHtmlTagInfo, inHtmlFlow, parse } = 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": [ "MD034", "no-bare-urls" ],
|
|
13
|
+
"description": "Bare URL used",
|
|
14
|
+
"tags": [ "links", "url" ],
|
|
15
|
+
"parser": "micromark",
|
|
16
|
+
"function": function MD034(params, onError) {
|
|
17
|
+
const literalAutolinks = (tokens) => (
|
|
18
|
+
filterByPredicate(
|
|
19
|
+
tokens,
|
|
20
|
+
(token) => {
|
|
21
|
+
if ((token.type === "literalAutolink") && !inHtmlFlow(token)) {
|
|
22
|
+
// Detect and ignore https://github.com/micromark/micromark/issues/164
|
|
23
|
+
const siblings = token.parent?.children;
|
|
24
|
+
// Commented-out due to not being able to exercise in test/code coverage
|
|
25
|
+
// || micromarkTokens;
|
|
26
|
+
const index = siblings?.indexOf(token);
|
|
27
|
+
// @ts-ignore
|
|
28
|
+
const prev = siblings?.at(index - 1);
|
|
29
|
+
// @ts-ignore
|
|
30
|
+
const next = siblings?.at(index + 1);
|
|
31
|
+
return !(
|
|
32
|
+
prev &&
|
|
33
|
+
next &&
|
|
34
|
+
(prev.type === "data") &&
|
|
35
|
+
(next.type === "data") &&
|
|
36
|
+
prev.text.endsWith("<") &&
|
|
37
|
+
next.text.startsWith(">")
|
|
38
|
+
);
|
|
39
|
+
}
|
|
40
|
+
return false;
|
|
41
|
+
},
|
|
42
|
+
(token) => {
|
|
43
|
+
const { children } = token;
|
|
44
|
+
const result = [];
|
|
45
|
+
for (let i = 0; i < children.length; i++) {
|
|
46
|
+
const current = children[i];
|
|
47
|
+
const openTagInfo = getHtmlTagInfo(current);
|
|
48
|
+
if (openTagInfo && !openTagInfo.close) {
|
|
49
|
+
let count = 1;
|
|
50
|
+
for (let j = i + 1; j < children.length; j++) {
|
|
51
|
+
const candidate = children[j];
|
|
52
|
+
const closeTagInfo = getHtmlTagInfo(candidate);
|
|
53
|
+
if (closeTagInfo && (openTagInfo.name === closeTagInfo.name)) {
|
|
54
|
+
if (closeTagInfo.close) {
|
|
55
|
+
count--;
|
|
56
|
+
if (count === 0) {
|
|
57
|
+
i = j;
|
|
58
|
+
break;
|
|
59
|
+
}
|
|
60
|
+
} else {
|
|
61
|
+
count++;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
} else {
|
|
66
|
+
result.push(current);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
return result;
|
|
70
|
+
}
|
|
71
|
+
)
|
|
72
|
+
);
|
|
73
|
+
const autoLinks = filterByTypesCached([ "literalAutolink" ]);
|
|
74
|
+
if (autoLinks.length > 0) {
|
|
75
|
+
// Re-parse with correct link/image reference definition handling
|
|
76
|
+
const document = params.lines.join("\n");
|
|
77
|
+
const tokens = parse(document, undefined, false);
|
|
78
|
+
for (const token of literalAutolinks(tokens)) {
|
|
79
|
+
const range = [
|
|
80
|
+
token.startColumn,
|
|
81
|
+
token.endColumn - token.startColumn
|
|
82
|
+
];
|
|
83
|
+
const fixInfo = {
|
|
84
|
+
"editColumn": range[0],
|
|
85
|
+
"deleteCount": range[1],
|
|
86
|
+
"insertText": `<${token.text}>`
|
|
87
|
+
};
|
|
88
|
+
addErrorContext(
|
|
89
|
+
onError,
|
|
90
|
+
token.startLine,
|
|
91
|
+
token.text,
|
|
92
|
+
undefined,
|
|
93
|
+
undefined,
|
|
94
|
+
range,
|
|
95
|
+
fixInfo
|
|
96
|
+
);
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
// @ts-check
|
|
2
|
+
|
|
3
|
+
"use strict";
|
|
4
|
+
|
|
5
|
+
const { 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": [ "MD035", "hr-style" ],
|
|
12
|
+
"description": "Horizontal rule style",
|
|
13
|
+
"tags": [ "hr" ],
|
|
14
|
+
"parser": "micromark",
|
|
15
|
+
"function": function MD035(params, onError) {
|
|
16
|
+
let style = String(params.config.style || "consistent").trim();
|
|
17
|
+
const thematicBreaks = filterByTypesCached([ "thematicBreak" ]);
|
|
18
|
+
for (const token of thematicBreaks) {
|
|
19
|
+
const { startLine, text } = token;
|
|
20
|
+
if (style === "consistent") {
|
|
21
|
+
style = text;
|
|
22
|
+
}
|
|
23
|
+
addErrorDetailIf(onError, startLine, style, text);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
};
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
// @ts-check
|
|
2
|
+
|
|
3
|
+
"use strict";
|
|
4
|
+
|
|
5
|
+
const { addErrorContext, allPunctuation } = require("../helpers");
|
|
6
|
+
const { matchAndGetTokensByType } = require("../helpers/micromark.cjs");
|
|
7
|
+
const { filterByTypesCached } = require("./cache");
|
|
8
|
+
|
|
9
|
+
/** @typedef {import("../helpers/micromark.cjs").TokenType} TokenType */
|
|
10
|
+
/** @type {Map<TokenType, TokenType[]>} */
|
|
11
|
+
const emphasisAndChildrenTypes = new Map([
|
|
12
|
+
[ "emphasis", [ "emphasisSequence", "emphasisText", "emphasisSequence" ] ],
|
|
13
|
+
[ "strong", [ "strongSequence", "strongText", "strongSequence" ] ]
|
|
14
|
+
]);
|
|
15
|
+
|
|
16
|
+
// eslint-disable-next-line jsdoc/valid-types
|
|
17
|
+
/** @type import("./markdownlint").Rule */
|
|
18
|
+
module.exports = {
|
|
19
|
+
"names": [ "MD036", "no-emphasis-as-heading" ],
|
|
20
|
+
"description": "Emphasis used instead of a heading",
|
|
21
|
+
"tags": [ "headings", "emphasis" ],
|
|
22
|
+
"parser": "micromark",
|
|
23
|
+
"function": function MD036(params, onError) {
|
|
24
|
+
let punctuation = params.config.punctuation;
|
|
25
|
+
punctuation = String((punctuation === undefined) ? allPunctuation : punctuation);
|
|
26
|
+
const punctuationRe = new RegExp("[" + punctuation + "]$");
|
|
27
|
+
const paragraphTokens =
|
|
28
|
+
filterByTypesCached([ "paragraph" ]).
|
|
29
|
+
filter((token) =>
|
|
30
|
+
(token.parent?.type === "content") && !token.parent?.parent && (token.children.length === 1)
|
|
31
|
+
);
|
|
32
|
+
for (const paragraphToken of paragraphTokens) {
|
|
33
|
+
const childToken = paragraphToken.children[0];
|
|
34
|
+
for (const [ emphasisType, emphasisChildrenTypes ] of emphasisAndChildrenTypes) {
|
|
35
|
+
if (childToken.type === emphasisType) {
|
|
36
|
+
const matchingTokens = matchAndGetTokensByType(childToken.children, emphasisChildrenTypes);
|
|
37
|
+
if (matchingTokens) {
|
|
38
|
+
const textToken = matchingTokens[1];
|
|
39
|
+
if (
|
|
40
|
+
(textToken.children.length === 1) &&
|
|
41
|
+
(textToken.children[0].type === "data") &&
|
|
42
|
+
!punctuationRe.test(textToken.text)
|
|
43
|
+
) {
|
|
44
|
+
addErrorContext(onError, textToken.startLine, textToken.text);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
};
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
// @ts-check
|
|
2
|
+
|
|
3
|
+
"use strict";
|
|
4
|
+
|
|
5
|
+
const { addError } = require("../helpers");
|
|
6
|
+
const { filterByPredicate, inHtmlFlow } = require("../helpers/micromark.cjs");
|
|
7
|
+
|
|
8
|
+
// eslint-disable-next-line jsdoc/valid-types
|
|
9
|
+
/** @type import("./markdownlint").Rule */
|
|
10
|
+
module.exports = {
|
|
11
|
+
"names": [ "MD037", "no-space-in-emphasis" ],
|
|
12
|
+
"description": "Spaces inside emphasis markers",
|
|
13
|
+
"tags": [ "whitespace", "emphasis" ],
|
|
14
|
+
"parser": "micromark",
|
|
15
|
+
"function": function MD037(params, onError) {
|
|
16
|
+
|
|
17
|
+
// Initialize variables
|
|
18
|
+
const { lines, parsers } = params;
|
|
19
|
+
const emphasisTokensByMarker = new Map();
|
|
20
|
+
for (const marker of [ "_", "__", "___", "*", "**", "***" ]) {
|
|
21
|
+
emphasisTokensByMarker.set(marker, []);
|
|
22
|
+
}
|
|
23
|
+
const tokens = filterByPredicate(
|
|
24
|
+
parsers.micromark.tokens,
|
|
25
|
+
(token) => token.children.some((child) => child.type === "data")
|
|
26
|
+
);
|
|
27
|
+
for (const token of tokens) {
|
|
28
|
+
|
|
29
|
+
// Build lists of bare tokens for each emphasis marker type
|
|
30
|
+
for (const emphasisTokens of emphasisTokensByMarker.values()) {
|
|
31
|
+
emphasisTokens.length = 0;
|
|
32
|
+
}
|
|
33
|
+
for (const child of token.children) {
|
|
34
|
+
const { text, type } = child;
|
|
35
|
+
if ((type === "data") && (text.length <= 3)) {
|
|
36
|
+
const emphasisTokens = emphasisTokensByMarker.get(text);
|
|
37
|
+
if (emphasisTokens && !inHtmlFlow(child)) {
|
|
38
|
+
emphasisTokens.push(child);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
// Process bare tokens for each emphasis marker type
|
|
44
|
+
for (const entry of emphasisTokensByMarker.entries()) {
|
|
45
|
+
const [ marker, emphasisTokens ] = entry;
|
|
46
|
+
for (let i = 0; i + 1 < emphasisTokens.length; i += 2) {
|
|
47
|
+
|
|
48
|
+
// Process start token of start/end pair
|
|
49
|
+
const startToken = emphasisTokens[i];
|
|
50
|
+
const startLine = lines[startToken.startLine - 1];
|
|
51
|
+
const startSlice = startLine.slice(startToken.endColumn - 1);
|
|
52
|
+
const startMatch = startSlice.match(/^\s+\S/);
|
|
53
|
+
if (startMatch) {
|
|
54
|
+
const [ startSpaceCharacter ] = startMatch;
|
|
55
|
+
const startContext = `${marker}${startSpaceCharacter}`;
|
|
56
|
+
addError(
|
|
57
|
+
onError,
|
|
58
|
+
startToken.startLine,
|
|
59
|
+
undefined,
|
|
60
|
+
startContext,
|
|
61
|
+
[ startToken.startColumn, startContext.length ],
|
|
62
|
+
{
|
|
63
|
+
"editColumn": startToken.endColumn,
|
|
64
|
+
"deleteCount": startSpaceCharacter.length - 1
|
|
65
|
+
}
|
|
66
|
+
);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
// Process end token of start/end pair
|
|
70
|
+
const endToken = emphasisTokens[i + 1];
|
|
71
|
+
const endLine = lines[endToken.startLine - 1];
|
|
72
|
+
const endSlice = endLine.slice(0, endToken.startColumn - 1);
|
|
73
|
+
const endMatch = endSlice.match(/\S\s+$/);
|
|
74
|
+
if (endMatch) {
|
|
75
|
+
const [ endSpaceCharacter ] = endMatch;
|
|
76
|
+
const endContext = `${endSpaceCharacter}${marker}`;
|
|
77
|
+
addError(
|
|
78
|
+
onError,
|
|
79
|
+
endToken.startLine,
|
|
80
|
+
undefined,
|
|
81
|
+
endContext,
|
|
82
|
+
[ endToken.endColumn - endContext.length, endContext.length ],
|
|
83
|
+
{
|
|
84
|
+
"editColumn":
|
|
85
|
+
endToken.startColumn - (endSpaceCharacter.length - 1),
|
|
86
|
+
"deleteCount": endSpaceCharacter.length - 1
|
|
87
|
+
}
|
|
88
|
+
);
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
};
|