@alexlit/lint-kit 190.0.1 → 191.0.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.
Files changed (171) hide show
  1. package/package.json +1 -1
  2. package/packages/config-eslint/package.json +3 -3
  3. package/packages/config-markdownlint/package.json +2 -2
  4. package/packages/config-markdownlint/node_modules/ansi-regex/index.d.ts +0 -33
  5. package/packages/config-markdownlint/node_modules/ansi-regex/index.js +0 -14
  6. package/packages/config-markdownlint/node_modules/ansi-regex/license +0 -9
  7. package/packages/config-markdownlint/node_modules/ansi-regex/package.json +0 -61
  8. package/packages/config-markdownlint/node_modules/ansi-regex/readme.md +0 -66
  9. package/packages/config-markdownlint/node_modules/markdownlint/CHANGELOG.md +0 -529
  10. package/packages/config-markdownlint/node_modules/markdownlint/CONTRIBUTING.md +0 -92
  11. package/packages/config-markdownlint/node_modules/markdownlint/LICENSE +0 -21
  12. package/packages/config-markdownlint/node_modules/markdownlint/README.md +0 -1112
  13. package/packages/config-markdownlint/node_modules/markdownlint/doc/CustomRules.md +0 -194
  14. package/packages/config-markdownlint/node_modules/markdownlint/doc/Prettier.md +0 -27
  15. package/packages/config-markdownlint/node_modules/markdownlint/doc/ReleaseProcess.md +0 -20
  16. package/packages/config-markdownlint/node_modules/markdownlint/doc/Rules.md +0 -2858
  17. package/packages/config-markdownlint/node_modules/markdownlint/doc/md001.md +0 -51
  18. package/packages/config-markdownlint/node_modules/markdownlint/doc/md003.md +0 -59
  19. package/packages/config-markdownlint/node_modules/markdownlint/doc/md004.md +0 -50
  20. package/packages/config-markdownlint/node_modules/markdownlint/doc/md005.md +0 -53
  21. package/packages/config-markdownlint/node_modules/markdownlint/doc/md007.md +0 -52
  22. package/packages/config-markdownlint/node_modules/markdownlint/doc/md009.md +0 -50
  23. package/packages/config-markdownlint/node_modules/markdownlint/doc/md010.md +0 -62
  24. package/packages/config-markdownlint/node_modules/markdownlint/doc/md011.md +0 -30
  25. package/packages/config-markdownlint/node_modules/markdownlint/doc/md012.md +0 -38
  26. package/packages/config-markdownlint/node_modules/markdownlint/doc/md013.md +0 -58
  27. package/packages/config-markdownlint/node_modules/markdownlint/doc/md014.md +0 -54
  28. package/packages/config-markdownlint/node_modules/markdownlint/doc/md018.md +0 -27
  29. package/packages/config-markdownlint/node_modules/markdownlint/doc/md019.md +0 -28
  30. package/packages/config-markdownlint/node_modules/markdownlint/doc/md020.md +0 -29
  31. package/packages/config-markdownlint/node_modules/markdownlint/doc/md021.md +0 -31
  32. package/packages/config-markdownlint/node_modules/markdownlint/doc/md022.md +0 -67
  33. package/packages/config-markdownlint/node_modules/markdownlint/doc/md023.md +0 -33
  34. package/packages/config-markdownlint/node_modules/markdownlint/doc/md024.md +0 -44
  35. package/packages/config-markdownlint/node_modules/markdownlint/doc/md025.md +0 -49
  36. package/packages/config-markdownlint/node_modules/markdownlint/doc/md026.md +0 -40
  37. package/packages/config-markdownlint/node_modules/markdownlint/doc/md027.md +0 -32
  38. package/packages/config-markdownlint/node_modules/markdownlint/doc/md028.md +0 -44
  39. package/packages/config-markdownlint/node_modules/markdownlint/doc/md029.md +0 -100
  40. package/packages/config-markdownlint/node_modules/markdownlint/doc/md030.md +0 -82
  41. package/packages/config-markdownlint/node_modules/markdownlint/doc/md031.md +0 -50
  42. package/packages/config-markdownlint/node_modules/markdownlint/doc/md032.md +0 -55
  43. package/packages/config-markdownlint/node_modules/markdownlint/doc/md033.md +0 -33
  44. package/packages/config-markdownlint/node_modules/markdownlint/doc/md034.md +0 -55
  45. package/packages/config-markdownlint/node_modules/markdownlint/doc/md035.md +0 -44
  46. package/packages/config-markdownlint/node_modules/markdownlint/doc/md036.md +0 -45
  47. package/packages/config-markdownlint/node_modules/markdownlint/doc/md037.md +0 -37
  48. package/packages/config-markdownlint/node_modules/markdownlint/doc/md038.md +0 -52
  49. package/packages/config-markdownlint/node_modules/markdownlint/doc/md039.md +0 -21
  50. package/packages/config-markdownlint/node_modules/markdownlint/doc/md040.md +0 -52
  51. package/packages/config-markdownlint/node_modules/markdownlint/doc/md041.md +0 -64
  52. package/packages/config-markdownlint/node_modules/markdownlint/doc/md042.md +0 -38
  53. package/packages/config-markdownlint/node_modules/markdownlint/doc/md043.md +0 -87
  54. package/packages/config-markdownlint/node_modules/markdownlint/doc/md044.md +0 -45
  55. package/packages/config-markdownlint/node_modules/markdownlint/doc/md045.md +0 -48
  56. package/packages/config-markdownlint/node_modules/markdownlint/doc/md046.md +0 -40
  57. package/packages/config-markdownlint/node_modules/markdownlint/doc/md047.md +0 -34
  58. package/packages/config-markdownlint/node_modules/markdownlint/doc/md048.md +0 -42
  59. package/packages/config-markdownlint/node_modules/markdownlint/doc/md049.md +0 -36
  60. package/packages/config-markdownlint/node_modules/markdownlint/doc/md050.md +0 -35
  61. package/packages/config-markdownlint/node_modules/markdownlint/doc/md051.md +0 -117
  62. package/packages/config-markdownlint/node_modules/markdownlint/doc/md052.md +0 -52
  63. package/packages/config-markdownlint/node_modules/markdownlint/doc/md053.md +0 -38
  64. package/packages/config-markdownlint/node_modules/markdownlint/doc/md054.md +0 -100
  65. package/packages/config-markdownlint/node_modules/markdownlint/doc/md055.md +0 -55
  66. package/packages/config-markdownlint/node_modules/markdownlint/doc/md056.md +0 -37
  67. package/packages/config-markdownlint/node_modules/markdownlint/doc/md058.md +0 -48
  68. package/packages/config-markdownlint/node_modules/markdownlint/doc/md059.md +0 -33
  69. package/packages/config-markdownlint/node_modules/markdownlint/doc/md060.md +0 -130
  70. package/packages/config-markdownlint/node_modules/markdownlint/helpers/LICENSE +0 -21
  71. package/packages/config-markdownlint/node_modules/markdownlint/helpers/README.md +0 -29
  72. package/packages/config-markdownlint/node_modules/markdownlint/helpers/helpers.cjs +0 -695
  73. package/packages/config-markdownlint/node_modules/markdownlint/helpers/micromark-helpers.cjs +0 -332
  74. package/packages/config-markdownlint/node_modules/markdownlint/helpers/package.json +0 -26
  75. package/packages/config-markdownlint/node_modules/markdownlint/helpers/shared.cjs +0 -16
  76. package/packages/config-markdownlint/node_modules/markdownlint/lib/cache.mjs +0 -80
  77. package/packages/config-markdownlint/node_modules/markdownlint/lib/configuration-strict.d.ts +0 -2417
  78. package/packages/config-markdownlint/node_modules/markdownlint/lib/configuration.d.ts +0 -8
  79. package/packages/config-markdownlint/node_modules/markdownlint/lib/constants.mjs +0 -14
  80. package/packages/config-markdownlint/node_modules/markdownlint/lib/defer-require.cjs +0 -18
  81. package/packages/config-markdownlint/node_modules/markdownlint/lib/exports-async.d.mts +0 -1
  82. package/packages/config-markdownlint/node_modules/markdownlint/lib/exports-async.mjs +0 -3
  83. package/packages/config-markdownlint/node_modules/markdownlint/lib/exports-promise.d.mts +0 -1
  84. package/packages/config-markdownlint/node_modules/markdownlint/lib/exports-promise.mjs +0 -3
  85. package/packages/config-markdownlint/node_modules/markdownlint/lib/exports-sync.d.mts +0 -1
  86. package/packages/config-markdownlint/node_modules/markdownlint/lib/exports-sync.mjs +0 -3
  87. package/packages/config-markdownlint/node_modules/markdownlint/lib/exports.d.mts +0 -30
  88. package/packages/config-markdownlint/node_modules/markdownlint/lib/exports.mjs +0 -33
  89. package/packages/config-markdownlint/node_modules/markdownlint/lib/markdownit.cjs +0 -171
  90. package/packages/config-markdownlint/node_modules/markdownlint/lib/markdownlint.d.mts +0 -615
  91. package/packages/config-markdownlint/node_modules/markdownlint/lib/markdownlint.mjs +0 -1592
  92. package/packages/config-markdownlint/node_modules/markdownlint/lib/md001.mjs +0 -32
  93. package/packages/config-markdownlint/node_modules/markdownlint/lib/md003.mjs +0 -47
  94. package/packages/config-markdownlint/node_modules/markdownlint/lib/md004.mjs +0 -72
  95. package/packages/config-markdownlint/node_modules/markdownlint/lib/md005.mjs +0 -69
  96. package/packages/config-markdownlint/node_modules/markdownlint/lib/md007.mjs +0 -84
  97. package/packages/config-markdownlint/node_modules/markdownlint/lib/md009.mjs +0 -96
  98. package/packages/config-markdownlint/node_modules/markdownlint/lib/md010.mjs +0 -78
  99. package/packages/config-markdownlint/node_modules/markdownlint/lib/md011.mjs +0 -56
  100. package/packages/config-markdownlint/node_modules/markdownlint/lib/md012.mjs +0 -40
  101. package/packages/config-markdownlint/node_modules/markdownlint/lib/md013.mjs +0 -91
  102. package/packages/config-markdownlint/node_modules/markdownlint/lib/md014.mjs +0 -47
  103. package/packages/config-markdownlint/node_modules/markdownlint/lib/md018.mjs +0 -43
  104. package/packages/config-markdownlint/node_modules/markdownlint/lib/md019-md021.mjs +0 -77
  105. package/packages/config-markdownlint/node_modules/markdownlint/lib/md020.mjs +0 -68
  106. package/packages/config-markdownlint/node_modules/markdownlint/lib/md022.mjs +0 -103
  107. package/packages/config-markdownlint/node_modules/markdownlint/lib/md023.mjs +0 -37
  108. package/packages/config-markdownlint/node_modules/markdownlint/lib/md024.mjs +0 -45
  109. package/packages/config-markdownlint/node_modules/markdownlint/lib/md025.mjs +0 -45
  110. package/packages/config-markdownlint/node_modules/markdownlint/lib/md026.mjs +0 -46
  111. package/packages/config-markdownlint/node_modules/markdownlint/lib/md027.mjs +0 -50
  112. package/packages/config-markdownlint/node_modules/markdownlint/lib/md028.mjs +0 -39
  113. package/packages/config-markdownlint/node_modules/markdownlint/lib/md029.mjs +0 -84
  114. package/packages/config-markdownlint/node_modules/markdownlint/lib/md030.mjs +0 -57
  115. package/packages/config-markdownlint/node_modules/markdownlint/lib/md031.mjs +0 -61
  116. package/packages/config-markdownlint/node_modules/markdownlint/lib/md032.mjs +0 -78
  117. package/packages/config-markdownlint/node_modules/markdownlint/lib/md033.mjs +0 -46
  118. package/packages/config-markdownlint/node_modules/markdownlint/lib/md034.mjs +0 -92
  119. package/packages/config-markdownlint/node_modules/markdownlint/lib/md035.mjs +0 -23
  120. package/packages/config-markdownlint/node_modules/markdownlint/lib/md036.mjs +0 -55
  121. package/packages/config-markdownlint/node_modules/markdownlint/lib/md037.mjs +0 -94
  122. package/packages/config-markdownlint/node_modules/markdownlint/lib/md038.mjs +0 -73
  123. package/packages/config-markdownlint/node_modules/markdownlint/lib/md039.mjs +0 -59
  124. package/packages/config-markdownlint/node_modules/markdownlint/lib/md040.mjs +0 -32
  125. package/packages/config-markdownlint/node_modules/markdownlint/lib/md041.mjs +0 -71
  126. package/packages/config-markdownlint/node_modules/markdownlint/lib/md042.mjs +0 -58
  127. package/packages/config-markdownlint/node_modules/markdownlint/lib/md043.mjs +0 -72
  128. package/packages/config-markdownlint/node_modules/markdownlint/lib/md044.mjs +0 -110
  129. package/packages/config-markdownlint/node_modules/markdownlint/lib/md045.mjs +0 -61
  130. package/packages/config-markdownlint/node_modules/markdownlint/lib/md046.mjs +0 -31
  131. package/packages/config-markdownlint/node_modules/markdownlint/lib/md047.mjs +0 -28
  132. package/packages/config-markdownlint/node_modules/markdownlint/lib/md048.mjs +0 -47
  133. package/packages/config-markdownlint/node_modules/markdownlint/lib/md049-md050.mjs +0 -115
  134. package/packages/config-markdownlint/node_modules/markdownlint/lib/md051.mjs +0 -173
  135. package/packages/config-markdownlint/node_modules/markdownlint/lib/md052.mjs +0 -40
  136. package/packages/config-markdownlint/node_modules/markdownlint/lib/md053.mjs +0 -60
  137. package/packages/config-markdownlint/node_modules/markdownlint/lib/md054.mjs +0 -122
  138. package/packages/config-markdownlint/node_modules/markdownlint/lib/md055.mjs +0 -72
  139. package/packages/config-markdownlint/node_modules/markdownlint/lib/md056.mjs +0 -50
  140. package/packages/config-markdownlint/node_modules/markdownlint/lib/md058.mjs +0 -57
  141. package/packages/config-markdownlint/node_modules/markdownlint/lib/md059.mjs +0 -71
  142. package/packages/config-markdownlint/node_modules/markdownlint/lib/md060.mjs +0 -209
  143. package/packages/config-markdownlint/node_modules/markdownlint/lib/micromark-parse.mjs +0 -337
  144. package/packages/config-markdownlint/node_modules/markdownlint/lib/micromark-types.d.mts +0 -11
  145. package/packages/config-markdownlint/node_modules/markdownlint/lib/node-imports-browser.mjs +0 -22
  146. package/packages/config-markdownlint/node_modules/markdownlint/lib/node-imports-node.mjs +0 -11
  147. package/packages/config-markdownlint/node_modules/markdownlint/lib/parse-configuration.mjs +0 -47
  148. package/packages/config-markdownlint/node_modules/markdownlint/lib/resolve-module.cjs +0 -52
  149. package/packages/config-markdownlint/node_modules/markdownlint/lib/resolve-module.d.cts +0 -34
  150. package/packages/config-markdownlint/node_modules/markdownlint/lib/rules.mjs +0 -122
  151. package/packages/config-markdownlint/node_modules/markdownlint/lib/types.d.mts +0 -13
  152. package/packages/config-markdownlint/node_modules/markdownlint/package.json +0 -120
  153. package/packages/config-markdownlint/node_modules/markdownlint/schema/.markdownlint.jsonc +0 -349
  154. package/packages/config-markdownlint/node_modules/markdownlint/schema/.markdownlint.yaml +0 -310
  155. package/packages/config-markdownlint/node_modules/markdownlint/schema/ValidatingConfiguration.md +0 -26
  156. package/packages/config-markdownlint/node_modules/markdownlint/schema/markdownlint-config-schema-strict.json +0 -5138
  157. package/packages/config-markdownlint/node_modules/markdownlint/schema/markdownlint-config-schema.json +0 -5143
  158. package/packages/config-markdownlint/node_modules/markdownlint/style/all.json +0 -5
  159. package/packages/config-markdownlint/node_modules/markdownlint/style/cirosantilli.json +0 -22
  160. package/packages/config-markdownlint/node_modules/markdownlint/style/prettier.json +0 -27
  161. package/packages/config-markdownlint/node_modules/markdownlint/style/relaxed.json +0 -12
  162. package/packages/config-markdownlint/node_modules/string-width/index.d.ts +0 -39
  163. package/packages/config-markdownlint/node_modules/string-width/index.js +0 -203
  164. package/packages/config-markdownlint/node_modules/string-width/license +0 -9
  165. package/packages/config-markdownlint/node_modules/string-width/package.json +0 -65
  166. package/packages/config-markdownlint/node_modules/string-width/readme.md +0 -66
  167. package/packages/config-markdownlint/node_modules/strip-ansi/index.d.ts +0 -15
  168. package/packages/config-markdownlint/node_modules/strip-ansi/index.js +0 -19
  169. package/packages/config-markdownlint/node_modules/strip-ansi/license +0 -9
  170. package/packages/config-markdownlint/node_modules/strip-ansi/package.json +0 -59
  171. package/packages/config-markdownlint/node_modules/strip-ansi/readme.md +0 -37
@@ -1,59 +0,0 @@
1
- // @ts-check
2
-
3
- import { addErrorContext } from "../helpers/helpers.cjs";
4
- import { filterByTypesCached } from "./cache.mjs";
5
-
6
- /**
7
- * Adds an error for a label space issue.
8
- *
9
- * @param {import("markdownlint").RuleOnError} onError Error-reporting callback.
10
- * @param {import("markdownlint").MicromarkToken} label Label token.
11
- * @param {import("markdownlint").MicromarkToken} labelText LabelText token.
12
- * @param {boolean} isStart True iff error is at the start of the link.
13
- */
14
- function addLabelSpaceError(onError, label, labelText, isStart) {
15
- const match = labelText.text.match(isStart ? /^[^\S\r\n]+/ : /[^\S\r\n]+$/);
16
- const range = match ?
17
- [
18
- (isStart ? (labelText.startColumn) : (labelText.endColumn - match[0].length)),
19
- match[0].length
20
- ] :
21
- undefined;
22
- addErrorContext(
23
- onError,
24
- isStart ? (labelText.startLine + (match ? 0 : 1)) : (labelText.endLine - (match ? 0 : 1)),
25
- label.text.replace(/\s+/g, " "),
26
- isStart,
27
- !isStart,
28
- range,
29
- range ?
30
- {
31
- "editColumn": range[0],
32
- "deleteCount": range[1]
33
- } :
34
- undefined
35
- );
36
- }
37
-
38
- /** @type {import("markdownlint").Rule} */
39
- export default {
40
- "names": [ "MD039", "no-space-in-links" ],
41
- "description": "Spaces inside link text",
42
- "tags": [ "whitespace", "links" ],
43
- "parser": "micromark",
44
- "function": function MD039(params, onError) {
45
- const labels = filterByTypesCached([ "label" ])
46
- .filter((label) => label.parent?.type === "link");
47
- for (const label of labels) {
48
- const labelTexts = label.children.filter((child) => child.type === "labelText");
49
- for (const labelText of labelTexts) {
50
- if (labelText.text.trimStart().length !== labelText.text.length) {
51
- addLabelSpaceError(onError, label, labelText, true);
52
- }
53
- if (labelText.text.trimEnd().length !== labelText.text.length) {
54
- addLabelSpaceError(onError, label, labelText, false);
55
- }
56
- }
57
- }
58
- }
59
- };
@@ -1,32 +0,0 @@
1
- // @ts-check
2
-
3
- import { addError, addErrorContext } from "../helpers/helpers.cjs";
4
- import { getDescendantsByType } from "../helpers/micromark-helpers.cjs";
5
- import { filterByTypesCached } from "./cache.mjs";
6
-
7
- /** @type {import("markdownlint").Rule} */
8
- export default {
9
- "names": [ "MD040", "fenced-code-language" ],
10
- "description": "Fenced code blocks should have a language specified",
11
- "tags": [ "code", "language" ],
12
- "parser": "micromark",
13
- "function": function MD040(params, onError) {
14
- let allowed = params.config.allowed_languages;
15
- allowed = Array.isArray(allowed) ? allowed : [];
16
- const languageOnly = !!params.config.language_only;
17
- const fencedCodes = filterByTypesCached([ "codeFenced" ]);
18
- for (const fencedCode of fencedCodes) {
19
- const openingFence = getDescendantsByType(fencedCode, [ "codeFencedFence" ])[0];
20
- const { startLine, text } = openingFence;
21
- const info = getDescendantsByType(openingFence, [ "codeFencedFenceInfo" ])[0]?.text;
22
- if (!info) {
23
- addErrorContext(onError, startLine, text);
24
- } else if ((allowed.length > 0) && !allowed.includes(info)) {
25
- addError(onError, startLine, `"${info}" is not allowed`);
26
- }
27
- if (languageOnly && getDescendantsByType(openingFence, [ "codeFencedFenceMeta" ]).length > 0) {
28
- addError(onError, startLine, `Info string contains more than language: "${text}"`);
29
- }
30
- }
31
- }
32
- };
@@ -1,71 +0,0 @@
1
- // @ts-check
2
-
3
- import { addErrorContext, frontMatterHasTitle } from "../helpers/helpers.cjs";
4
- import { filterByTypes, getHeadingLevel, getHtmlTagInfo, isHtmlFlowComment, nonContentTokens } from "../helpers/micromark-helpers.cjs";
5
-
6
- const headingTagNameRe = /^h[1-6]$/;
7
-
8
- /**
9
- * Gets the HTML tag name of an htmlFlow token.
10
- *
11
- * @param {import("markdownlint").MicromarkToken} token Micromark Token.
12
- * @returns {string | null} Tag name.
13
- */
14
- function getHtmlFlowTagName(token) {
15
- const { children, type } = token;
16
- if (type === "htmlFlow") {
17
- const htmlTexts = filterByTypes(children, [ "htmlText" ], true);
18
- const tagInfo = (htmlTexts.length > 0) && getHtmlTagInfo(htmlTexts[0]);
19
- if (tagInfo) {
20
- return tagInfo.name.toLowerCase();
21
- }
22
- }
23
- return null;
24
- }
25
-
26
- /** @type {import("markdownlint").Rule} */
27
- export default {
28
- "names": [ "MD041", "first-line-heading", "first-line-h1" ],
29
- "description": "First line in a file should be a top-level heading",
30
- "tags": [ "headings" ],
31
- "parser": "micromark",
32
- "function": function MD041(params, onError) {
33
- const allowPreamble = !!params.config.allow_preamble;
34
- const level = Number(params.config.level || 1);
35
- const { tokens } = params.parsers.micromark;
36
- if (
37
- !frontMatterHasTitle(
38
- params.frontMatterLines,
39
- params.config.front_matter_title
40
- )
41
- ) {
42
- let errorLineNumber = 0;
43
- for (const token of tokens) {
44
- const { startLine, type } = token;
45
- if (!nonContentTokens.has(type) && !isHtmlFlowComment(token)) {
46
- let tagName = null;
47
- if ((type === "atxHeading") || (type === "setextHeading")) {
48
- // First heading needs to have the expected level
49
- if (getHeadingLevel(token) !== level) {
50
- errorLineNumber = startLine;
51
- }
52
- break;
53
- } else if ((tagName = getHtmlFlowTagName(token)) && headingTagNameRe.test(tagName)) {
54
- // First HTML element needs to have an <h?> with the expected level
55
- if (tagName !== `h${level}`) {
56
- errorLineNumber = startLine;
57
- }
58
- break;
59
- } else if (!allowPreamble) {
60
- // First non-content needs to be a heading with the expected level
61
- errorLineNumber = startLine;
62
- break;
63
- }
64
- }
65
- }
66
- if (errorLineNumber > 0) {
67
- addErrorContext(onError, errorLineNumber, params.lines[errorLineNumber - 1]);
68
- }
69
- }
70
- }
71
- };
@@ -1,58 +0,0 @@
1
- // @ts-check
2
-
3
- import { addErrorContext } from "../helpers/helpers.cjs";
4
- import { getDescendantsByType } from "../helpers/micromark-helpers.cjs";
5
- import { getReferenceLinkImageData, filterByTypesCached } from "./cache.mjs";
6
-
7
- /** @typedef {import("markdownlint").MicromarkToken} MicromarkToken */
8
-
9
- /** @type {import("markdownlint").Rule} */
10
- export default {
11
- "names": [ "MD042", "no-empty-links" ],
12
- "description": "No empty links",
13
- "tags": [ "links" ],
14
- "parser": "micromark",
15
- "function": function MD042(params, onError) {
16
- const { definitions } = getReferenceLinkImageData();
17
- const isReferenceDefinitionHash = (/** @type {MicromarkToken} */ token) => {
18
- const definition = definitions.get(token.text.trim());
19
- return Boolean(definition && (definition[1] === "#"));
20
- };
21
- const links = filterByTypesCached([ "link" ]);
22
- for (const link of links) {
23
- const labelText = getDescendantsByType(link, [ "label", "labelText" ]);
24
- const reference = getDescendantsByType(link, [ "reference" ]);
25
- const resource = getDescendantsByType(link, [ "resource" ]);
26
- const referenceString = getDescendantsByType(reference, [ "referenceString" ]);
27
- const resourceDestinationString = getDescendantsByType(resource, [ "resourceDestination", [ "resourceDestinationLiteral", "resourceDestinationRaw" ], "resourceDestinationString" ]);
28
- const hasLabelText = labelText.length > 0;
29
- const hasReference = reference.length > 0;
30
- const hasResource = resource.length > 0;
31
- const hasReferenceString = referenceString.length > 0;
32
- const hasResourceDestinationString = resourceDestinationString.length > 0;
33
- let error = false;
34
- if (
35
- hasLabelText &&
36
- ((!hasReference && !hasResource) || (hasReference && !hasReferenceString))
37
- ) {
38
- error = isReferenceDefinitionHash(labelText[0]);
39
- } else if (hasReferenceString && !hasResourceDestinationString) {
40
- error = isReferenceDefinitionHash(referenceString[0]);
41
- } else if (!hasReferenceString && hasResourceDestinationString) {
42
- error = (resourceDestinationString[0].text.trim() === "#");
43
- } else if (!hasReferenceString && !hasResourceDestinationString) {
44
- error = true;
45
- }
46
- if (error) {
47
- addErrorContext(
48
- onError,
49
- link.startLine,
50
- link.text,
51
- undefined,
52
- undefined,
53
- [ link.startColumn, link.endColumn - link.startColumn ]
54
- );
55
- }
56
- }
57
- }
58
- };
@@ -1,72 +0,0 @@
1
- // @ts-check
2
-
3
- import { addErrorContext, addErrorDetailIf } from "../helpers/helpers.cjs";
4
- import { getHeadingLevel, getHeadingText } from "../helpers/micromark-helpers.cjs";
5
- import { filterByTypesCached } from "./cache.mjs";
6
-
7
- /** @type {import("markdownlint").Rule} */
8
- export default {
9
- "names": [ "MD043", "required-headings" ],
10
- "description": "Required heading structure",
11
- "tags": [ "headings" ],
12
- "parser": "micromark",
13
- "function": function MD043(params, onError) {
14
- const requiredHeadings = params.config.headings;
15
- if (!Array.isArray(requiredHeadings)) {
16
- // Nothing to check; avoid doing any work
17
- return;
18
- }
19
- const matchCase = params.config.match_case || false;
20
- let i = 0;
21
- let matchAny = false;
22
- let hasError = false;
23
- let anyHeadings = false;
24
- const getExpected = () => String(requiredHeadings[i++] || "[None]");
25
- const handleCase = (/** @type {string} */ str) => (matchCase ? str : str.toLowerCase());
26
- for (const heading of filterByTypesCached([ "atxHeading", "setextHeading" ])) {
27
- if (!hasError) {
28
- const headingText = getHeadingText(heading);
29
- const headingLevel = getHeadingLevel(heading);
30
- anyHeadings = true;
31
- const actual = `${"".padEnd(headingLevel, "#")} ${headingText}`;
32
- const expected = getExpected();
33
- if (expected === "*") {
34
- const nextExpected = getExpected();
35
- if (handleCase(nextExpected) !== handleCase(actual)) {
36
- matchAny = true;
37
- i--;
38
- }
39
- } else if (expected === "+") {
40
- matchAny = true;
41
- } else if (expected === "?") {
42
- // Allow current, match next
43
- } else if (handleCase(expected) === handleCase(actual)) {
44
- matchAny = false;
45
- } else if (matchAny) {
46
- i--;
47
- } else {
48
- addErrorDetailIf(
49
- onError,
50
- heading.startLine,
51
- expected,
52
- actual
53
- );
54
- hasError = true;
55
- }
56
- }
57
- }
58
- const extraHeadings = requiredHeadings.length - i;
59
- if (
60
- !hasError &&
61
- ((extraHeadings > 1) ||
62
- ((extraHeadings === 1) && (requiredHeadings[i] !== "*"))) &&
63
- (anyHeadings || !requiredHeadings.every((heading) => heading === "*"))
64
- ) {
65
- addErrorContext(
66
- onError,
67
- params.lines.length,
68
- requiredHeadings[i]
69
- );
70
- }
71
- }
72
- };
@@ -1,110 +0,0 @@
1
- // @ts-check
2
-
3
- import { addErrorDetailIf, escapeForRegExp, hasOverlap } from "../helpers/helpers.cjs";
4
- import { filterByPredicate, filterByTypes } from "../helpers/micromark-helpers.cjs";
5
- import { parse } from "./micromark-parse.mjs";
6
-
7
- const ignoredChildTypes = new Set(
8
- [ "codeFencedFence", "definition", "reference", "resource" ]
9
- );
10
-
11
- /** @type {import("markdownlint").Rule} */
12
- export default {
13
- "names": [ "MD044", "proper-names" ],
14
- "description": "Proper names should have the correct capitalization",
15
- "tags": [ "spelling" ],
16
- "parser": "micromark",
17
- "function": function MD044(params, onError) {
18
- let names = params.config.names;
19
- names = Array.isArray(names) ? names : [];
20
- names.sort((/** @type {string} */ a, /** @type {string} */ b) => (b.length - a.length) || a.localeCompare(b));
21
- if (names.length === 0) {
22
- // Nothing to check; avoid doing any work
23
- return;
24
- }
25
- const codeBlocks = params.config.code_blocks;
26
- const includeCodeBlocks =
27
- (codeBlocks === undefined) ? true : !!codeBlocks;
28
- const htmlElements = params.config.html_elements;
29
- const includeHtmlElements =
30
- (htmlElements === undefined) ? true : !!htmlElements;
31
- const scannedTypes = new Set([ "data" ]);
32
- if (includeCodeBlocks) {
33
- scannedTypes.add("codeFlowValue");
34
- scannedTypes.add("codeTextData");
35
- }
36
- if (includeHtmlElements) {
37
- scannedTypes.add("htmlFlowData");
38
- scannedTypes.add("htmlTextData");
39
- }
40
- const contentTokens =
41
- filterByPredicate(
42
- params.parsers.micromark.tokens,
43
- (token) => scannedTypes.has(token.type),
44
- (token) => (
45
- token.children.filter((t) => !ignoredChildTypes.has(t.type))
46
- )
47
- );
48
- /** @type {import("../helpers/helpers.cjs").FileRange[]} */
49
- const exclusions = [];
50
- const scannedTokens = new Set();
51
- for (const name of names) {
52
- const escapedName = escapeForRegExp(name);
53
- const startNamePattern = /^\W/.test(name) ? "" : "\\b_*";
54
- const endNamePattern = /\W$/.test(name) ? "" : "_*\\b";
55
- const namePattern = `(${startNamePattern})(${escapedName})${endNamePattern}`;
56
- const nameRe = new RegExp(namePattern, "gi");
57
- for (const token of contentTokens) {
58
- let match = null;
59
- while ((match = nameRe.exec(token.text)) !== null) {
60
- const [ , leftMatch, nameMatch ] = match;
61
- const column = token.startColumn + match.index + leftMatch.length;
62
- const length = nameMatch.length;
63
- const lineNumber = token.startLine;
64
- /** @type {import("../helpers/helpers.cjs").FileRange} */
65
- const nameRange = {
66
- "startLine": lineNumber,
67
- "startColumn": column,
68
- "endLine": lineNumber,
69
- "endColumn": column + length - 1
70
- };
71
- if (
72
- !names.includes(nameMatch) &&
73
- !exclusions.some((exclusion) => hasOverlap(exclusion, nameRange))
74
- ) {
75
- /** @type {import("../helpers/helpers.cjs").FileRange[]} */
76
- let autolinkRanges = [];
77
- if (!scannedTokens.has(token)) {
78
- autolinkRanges = filterByTypes(parse(token.text), [ "literalAutolink" ])
79
- .map((tok) => ({
80
- "startLine": lineNumber,
81
- "startColumn": token.startColumn + tok.startColumn - 1,
82
- "endLine": lineNumber,
83
- "endColumn": token.endColumn + tok.endColumn - 1
84
- }));
85
- exclusions.push(...autolinkRanges);
86
- scannedTokens.add(token);
87
- }
88
- if (!autolinkRanges.some((autolinkRange) => hasOverlap(autolinkRange, nameRange))) {
89
- addErrorDetailIf(
90
- onError,
91
- token.startLine,
92
- name,
93
- nameMatch,
94
- undefined,
95
- undefined,
96
- [ column, length ],
97
- {
98
- "editColumn": column,
99
- "deleteCount": length,
100
- "insertText": name
101
- }
102
- );
103
- }
104
- }
105
- exclusions.push(nameRange);
106
- }
107
- }
108
- }
109
- }
110
- };
@@ -1,61 +0,0 @@
1
- // @ts-check
2
-
3
- import { addError, getHtmlAttributeRe, nextLinesRe } from "../helpers/helpers.cjs";
4
- import { getHtmlTagInfo, getDescendantsByType } from "../helpers/micromark-helpers.cjs";
5
- import { filterByTypesCached } from "./cache.mjs";
6
-
7
- const altRe = getHtmlAttributeRe("alt");
8
- const ariaHiddenRe = getHtmlAttributeRe("aria-hidden");
9
-
10
- /** @type {import("markdownlint").Rule} */
11
- export default {
12
- "names": [ "MD045", "no-alt-text" ],
13
- "description": "Images should have alternate text (alt text)",
14
- "tags": [ "accessibility", "images" ],
15
- "parser": "micromark",
16
- "function": function MD045(params, onError) {
17
- // Process Markdown images
18
- const images = filterByTypesCached([ "image" ]);
19
- for (const image of images) {
20
- const labelTexts = getDescendantsByType(image, [ "label", "labelText" ]);
21
- if (labelTexts.some((labelText) => labelText.text.length === 0)) {
22
- const range = (image.startLine === image.endLine) ?
23
- [ image.startColumn, image.endColumn - image.startColumn ] :
24
- undefined;
25
- addError(
26
- onError,
27
- image.startLine,
28
- undefined,
29
- undefined,
30
- range
31
- );
32
- }
33
- }
34
-
35
- // Process HTML images
36
- const htmlTexts = filterByTypesCached([ "htmlText" ], true);
37
- for (const htmlText of htmlTexts) {
38
- const { startColumn, startLine, text } = htmlText;
39
- const htmlTagInfo = getHtmlTagInfo(htmlText);
40
- if (
41
- htmlTagInfo &&
42
- !htmlTagInfo.close &&
43
- (htmlTagInfo.name.toLowerCase() === "img") &&
44
- !altRe.test(text) &&
45
- (ariaHiddenRe.exec(text)?.[1].toLowerCase() !== "true")
46
- ) {
47
- const range = [
48
- startColumn,
49
- text.replace(nextLinesRe, "").length
50
- ];
51
- addError(
52
- onError,
53
- startLine,
54
- undefined,
55
- undefined,
56
- range
57
- );
58
- }
59
- }
60
- }
61
- };
@@ -1,31 +0,0 @@
1
- // @ts-check
2
-
3
- import { addErrorDetailIf } from "../helpers/helpers.cjs";
4
- import { filterByTypesCached } from "./cache.mjs";
5
-
6
- /** @typedef {import("markdownlint").MicromarkTokenType} MicromarkTokenType */
7
-
8
- const tokenTypeToStyle = (/** @type {MicromarkTokenType} */ tokenType) => (tokenType === "codeFenced") ? "fenced" : "indented";
9
-
10
- /** @type {import("markdownlint").Rule} */
11
- export default {
12
- "names": [ "MD046", "code-block-style" ],
13
- "description": "Code block style",
14
- "tags": [ "code" ],
15
- "parser": "micromark",
16
- "function": function MD046(params, onError) {
17
- let expectedStyle = String(params.config.style || "consistent");
18
- for (const token of filterByTypesCached([ "codeFenced", "codeIndented" ])) {
19
- const { startLine, type } = token;
20
- if (expectedStyle === "consistent") {
21
- expectedStyle = tokenTypeToStyle(type);
22
- }
23
- addErrorDetailIf(
24
- onError,
25
- startLine,
26
- expectedStyle,
27
- tokenTypeToStyle(type)
28
- );
29
- }
30
- }
31
- };
@@ -1,28 +0,0 @@
1
- // @ts-check
2
-
3
- import { addError, isBlankLine } from "../helpers/helpers.cjs";
4
-
5
- /** @type {import("markdownlint").Rule} */
6
- export default {
7
- "names": [ "MD047", "single-trailing-newline" ],
8
- "description": "Files should end with a single newline character",
9
- "tags": [ "blank_lines" ],
10
- "parser": "none",
11
- "function": function MD047(params, onError) {
12
- const lastLineNumber = params.lines.length;
13
- const lastLine = params.lines[lastLineNumber - 1];
14
- if (!isBlankLine(lastLine)) {
15
- addError(
16
- onError,
17
- lastLineNumber,
18
- undefined,
19
- undefined,
20
- [ lastLine.length, 1 ],
21
- {
22
- "insertText": "\n",
23
- "editColumn": lastLine.length + 1
24
- }
25
- );
26
- }
27
- }
28
- };
@@ -1,47 +0,0 @@
1
- // @ts-check
2
-
3
- import { addErrorDetailIf } from "../helpers/helpers.cjs";
4
- import { getDescendantsByType } from "../helpers/micromark-helpers.cjs";
5
- import { filterByTypesCached } from "./cache.mjs";
6
-
7
- /**
8
- * Return the string representation of a fence markup character.
9
- *
10
- * @param {string} markup Fence string.
11
- * @returns {"tilde" | "backtick"} String representation.
12
- */
13
- function fencedCodeBlockStyleFor(markup) {
14
- switch (markup[0]) {
15
- case "~":
16
- return "tilde";
17
- default:
18
- return "backtick";
19
- }
20
- };
21
-
22
- /** @type {import("markdownlint").Rule} */
23
- export default {
24
- "names": [ "MD048", "code-fence-style" ],
25
- "description": "Code fence style",
26
- "tags": [ "code" ],
27
- "parser": "micromark",
28
- "function": function MD048(params, onError) {
29
- const style = String(params.config.style || "consistent");
30
- let expectedStyle = style;
31
- const codeFenceds = filterByTypesCached([ "codeFenced" ]);
32
- for (const codeFenced of codeFenceds) {
33
- const codeFencedFenceSequence =
34
- getDescendantsByType(codeFenced, [ "codeFencedFence", "codeFencedFenceSequence" ])[0];
35
- const { startLine, text } = codeFencedFenceSequence;
36
- if (expectedStyle === "consistent") {
37
- expectedStyle = fencedCodeBlockStyleFor(text);
38
- }
39
- addErrorDetailIf(
40
- onError,
41
- startLine,
42
- expectedStyle,
43
- fencedCodeBlockStyleFor(text)
44
- );
45
- }
46
- }
47
- };