@alexlit/lint-kit 189.1.0 → 190.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 (177) hide show
  1. package/package.json +1 -1
  2. package/packages/config-eslint/package.json +4 -4
  3. package/packages/config-eslint/plugins/json.js +1 -1
  4. package/packages/config-eslint/plugins/prettier.js +1 -1
  5. package/packages/config-eslint/plugins/unicorn.js +2 -1
  6. package/packages/config-markdownlint/node_modules/ansi-regex/index.d.ts +33 -0
  7. package/packages/config-markdownlint/node_modules/ansi-regex/index.js +14 -0
  8. package/packages/config-markdownlint/node_modules/ansi-regex/license +9 -0
  9. package/packages/config-markdownlint/node_modules/ansi-regex/package.json +61 -0
  10. package/packages/config-markdownlint/node_modules/ansi-regex/readme.md +66 -0
  11. package/packages/config-markdownlint/node_modules/markdownlint/CHANGELOG.md +529 -0
  12. package/packages/config-markdownlint/node_modules/markdownlint/CONTRIBUTING.md +92 -0
  13. package/packages/config-markdownlint/node_modules/markdownlint/LICENSE +21 -0
  14. package/packages/config-markdownlint/node_modules/markdownlint/README.md +1112 -0
  15. package/packages/config-markdownlint/node_modules/markdownlint/doc/CustomRules.md +194 -0
  16. package/packages/config-markdownlint/node_modules/markdownlint/doc/Prettier.md +27 -0
  17. package/packages/config-markdownlint/node_modules/markdownlint/doc/ReleaseProcess.md +20 -0
  18. package/packages/config-markdownlint/node_modules/markdownlint/doc/Rules.md +2858 -0
  19. package/packages/config-markdownlint/node_modules/markdownlint/doc/md001.md +51 -0
  20. package/packages/config-markdownlint/node_modules/markdownlint/doc/md003.md +59 -0
  21. package/packages/config-markdownlint/node_modules/markdownlint/doc/md004.md +50 -0
  22. package/packages/config-markdownlint/node_modules/markdownlint/doc/md005.md +53 -0
  23. package/packages/config-markdownlint/node_modules/markdownlint/doc/md007.md +52 -0
  24. package/packages/config-markdownlint/node_modules/markdownlint/doc/md009.md +50 -0
  25. package/packages/config-markdownlint/node_modules/markdownlint/doc/md010.md +62 -0
  26. package/packages/config-markdownlint/node_modules/markdownlint/doc/md011.md +30 -0
  27. package/packages/config-markdownlint/node_modules/markdownlint/doc/md012.md +38 -0
  28. package/packages/config-markdownlint/node_modules/markdownlint/doc/md013.md +58 -0
  29. package/packages/config-markdownlint/node_modules/markdownlint/doc/md014.md +54 -0
  30. package/packages/config-markdownlint/node_modules/markdownlint/doc/md018.md +27 -0
  31. package/packages/config-markdownlint/node_modules/markdownlint/doc/md019.md +28 -0
  32. package/packages/config-markdownlint/node_modules/markdownlint/doc/md020.md +29 -0
  33. package/packages/config-markdownlint/node_modules/markdownlint/doc/md021.md +31 -0
  34. package/packages/config-markdownlint/node_modules/markdownlint/doc/md022.md +67 -0
  35. package/packages/config-markdownlint/node_modules/markdownlint/doc/md023.md +33 -0
  36. package/packages/config-markdownlint/node_modules/markdownlint/doc/md024.md +44 -0
  37. package/packages/config-markdownlint/node_modules/markdownlint/doc/md025.md +49 -0
  38. package/packages/config-markdownlint/node_modules/markdownlint/doc/md026.md +40 -0
  39. package/packages/config-markdownlint/node_modules/markdownlint/doc/md027.md +32 -0
  40. package/packages/config-markdownlint/node_modules/markdownlint/doc/md028.md +44 -0
  41. package/packages/config-markdownlint/node_modules/markdownlint/doc/md029.md +100 -0
  42. package/packages/config-markdownlint/node_modules/markdownlint/doc/md030.md +82 -0
  43. package/packages/config-markdownlint/node_modules/markdownlint/doc/md031.md +50 -0
  44. package/packages/config-markdownlint/node_modules/markdownlint/doc/md032.md +55 -0
  45. package/packages/config-markdownlint/node_modules/markdownlint/doc/md033.md +33 -0
  46. package/packages/config-markdownlint/node_modules/markdownlint/doc/md034.md +55 -0
  47. package/packages/config-markdownlint/node_modules/markdownlint/doc/md035.md +44 -0
  48. package/packages/config-markdownlint/node_modules/markdownlint/doc/md036.md +45 -0
  49. package/packages/config-markdownlint/node_modules/markdownlint/doc/md037.md +37 -0
  50. package/packages/config-markdownlint/node_modules/markdownlint/doc/md038.md +52 -0
  51. package/packages/config-markdownlint/node_modules/markdownlint/doc/md039.md +21 -0
  52. package/packages/config-markdownlint/node_modules/markdownlint/doc/md040.md +52 -0
  53. package/packages/config-markdownlint/node_modules/markdownlint/doc/md041.md +64 -0
  54. package/packages/config-markdownlint/node_modules/markdownlint/doc/md042.md +38 -0
  55. package/packages/config-markdownlint/node_modules/markdownlint/doc/md043.md +87 -0
  56. package/packages/config-markdownlint/node_modules/markdownlint/doc/md044.md +45 -0
  57. package/packages/config-markdownlint/node_modules/markdownlint/doc/md045.md +48 -0
  58. package/packages/config-markdownlint/node_modules/markdownlint/doc/md046.md +40 -0
  59. package/packages/config-markdownlint/node_modules/markdownlint/doc/md047.md +34 -0
  60. package/packages/config-markdownlint/node_modules/markdownlint/doc/md048.md +42 -0
  61. package/packages/config-markdownlint/node_modules/markdownlint/doc/md049.md +36 -0
  62. package/packages/config-markdownlint/node_modules/markdownlint/doc/md050.md +35 -0
  63. package/packages/config-markdownlint/node_modules/markdownlint/doc/md051.md +117 -0
  64. package/packages/config-markdownlint/node_modules/markdownlint/doc/md052.md +52 -0
  65. package/packages/config-markdownlint/node_modules/markdownlint/doc/md053.md +38 -0
  66. package/packages/config-markdownlint/node_modules/markdownlint/doc/md054.md +100 -0
  67. package/packages/config-markdownlint/node_modules/markdownlint/doc/md055.md +55 -0
  68. package/packages/config-markdownlint/node_modules/markdownlint/doc/md056.md +37 -0
  69. package/packages/config-markdownlint/node_modules/markdownlint/doc/md058.md +48 -0
  70. package/packages/config-markdownlint/node_modules/markdownlint/doc/md059.md +33 -0
  71. package/packages/config-markdownlint/node_modules/markdownlint/doc/md060.md +130 -0
  72. package/packages/config-markdownlint/node_modules/markdownlint/helpers/LICENSE +21 -0
  73. package/packages/config-markdownlint/node_modules/markdownlint/helpers/README.md +29 -0
  74. package/packages/config-markdownlint/node_modules/markdownlint/helpers/helpers.cjs +695 -0
  75. package/packages/config-markdownlint/node_modules/markdownlint/helpers/micromark-helpers.cjs +332 -0
  76. package/packages/config-markdownlint/node_modules/markdownlint/helpers/package.json +26 -0
  77. package/packages/config-markdownlint/node_modules/markdownlint/helpers/shared.cjs +16 -0
  78. package/packages/config-markdownlint/node_modules/markdownlint/lib/cache.mjs +80 -0
  79. package/packages/config-markdownlint/node_modules/markdownlint/lib/configuration-strict.d.ts +2417 -0
  80. package/packages/config-markdownlint/node_modules/markdownlint/lib/configuration.d.ts +8 -0
  81. package/packages/config-markdownlint/node_modules/markdownlint/lib/constants.mjs +14 -0
  82. package/packages/config-markdownlint/node_modules/markdownlint/lib/defer-require.cjs +18 -0
  83. package/packages/config-markdownlint/node_modules/markdownlint/lib/exports-async.d.mts +1 -0
  84. package/packages/config-markdownlint/node_modules/markdownlint/lib/exports-async.mjs +3 -0
  85. package/packages/config-markdownlint/node_modules/markdownlint/lib/exports-promise.d.mts +1 -0
  86. package/packages/config-markdownlint/node_modules/markdownlint/lib/exports-promise.mjs +3 -0
  87. package/packages/config-markdownlint/node_modules/markdownlint/lib/exports-sync.d.mts +1 -0
  88. package/packages/config-markdownlint/node_modules/markdownlint/lib/exports-sync.mjs +3 -0
  89. package/packages/config-markdownlint/node_modules/markdownlint/lib/exports.d.mts +30 -0
  90. package/packages/config-markdownlint/node_modules/markdownlint/lib/exports.mjs +33 -0
  91. package/packages/config-markdownlint/node_modules/markdownlint/lib/markdownit.cjs +171 -0
  92. package/packages/config-markdownlint/node_modules/markdownlint/lib/markdownlint.d.mts +615 -0
  93. package/packages/config-markdownlint/node_modules/markdownlint/lib/markdownlint.mjs +1592 -0
  94. package/packages/config-markdownlint/node_modules/markdownlint/lib/md001.mjs +32 -0
  95. package/packages/config-markdownlint/node_modules/markdownlint/lib/md003.mjs +47 -0
  96. package/packages/config-markdownlint/node_modules/markdownlint/lib/md004.mjs +72 -0
  97. package/packages/config-markdownlint/node_modules/markdownlint/lib/md005.mjs +69 -0
  98. package/packages/config-markdownlint/node_modules/markdownlint/lib/md007.mjs +84 -0
  99. package/packages/config-markdownlint/node_modules/markdownlint/lib/md009.mjs +96 -0
  100. package/packages/config-markdownlint/node_modules/markdownlint/lib/md010.mjs +78 -0
  101. package/packages/config-markdownlint/node_modules/markdownlint/lib/md011.mjs +56 -0
  102. package/packages/config-markdownlint/node_modules/markdownlint/lib/md012.mjs +40 -0
  103. package/packages/config-markdownlint/node_modules/markdownlint/lib/md013.mjs +91 -0
  104. package/packages/config-markdownlint/node_modules/markdownlint/lib/md014.mjs +47 -0
  105. package/packages/config-markdownlint/node_modules/markdownlint/lib/md018.mjs +43 -0
  106. package/packages/config-markdownlint/node_modules/markdownlint/lib/md019-md021.mjs +77 -0
  107. package/packages/config-markdownlint/node_modules/markdownlint/lib/md020.mjs +68 -0
  108. package/packages/config-markdownlint/node_modules/markdownlint/lib/md022.mjs +103 -0
  109. package/packages/config-markdownlint/node_modules/markdownlint/lib/md023.mjs +37 -0
  110. package/packages/config-markdownlint/node_modules/markdownlint/lib/md024.mjs +45 -0
  111. package/packages/config-markdownlint/node_modules/markdownlint/lib/md025.mjs +45 -0
  112. package/packages/config-markdownlint/node_modules/markdownlint/lib/md026.mjs +46 -0
  113. package/packages/config-markdownlint/node_modules/markdownlint/lib/md027.mjs +50 -0
  114. package/packages/config-markdownlint/node_modules/markdownlint/lib/md028.mjs +39 -0
  115. package/packages/config-markdownlint/node_modules/markdownlint/lib/md029.mjs +84 -0
  116. package/packages/config-markdownlint/node_modules/markdownlint/lib/md030.mjs +57 -0
  117. package/packages/config-markdownlint/node_modules/markdownlint/lib/md031.mjs +61 -0
  118. package/packages/config-markdownlint/node_modules/markdownlint/lib/md032.mjs +78 -0
  119. package/packages/config-markdownlint/node_modules/markdownlint/lib/md033.mjs +46 -0
  120. package/packages/config-markdownlint/node_modules/markdownlint/lib/md034.mjs +92 -0
  121. package/packages/config-markdownlint/node_modules/markdownlint/lib/md035.mjs +23 -0
  122. package/packages/config-markdownlint/node_modules/markdownlint/lib/md036.mjs +55 -0
  123. package/packages/config-markdownlint/node_modules/markdownlint/lib/md037.mjs +94 -0
  124. package/packages/config-markdownlint/node_modules/markdownlint/lib/md038.mjs +73 -0
  125. package/packages/config-markdownlint/node_modules/markdownlint/lib/md039.mjs +59 -0
  126. package/packages/config-markdownlint/node_modules/markdownlint/lib/md040.mjs +32 -0
  127. package/packages/config-markdownlint/node_modules/markdownlint/lib/md041.mjs +71 -0
  128. package/packages/config-markdownlint/node_modules/markdownlint/lib/md042.mjs +58 -0
  129. package/packages/config-markdownlint/node_modules/markdownlint/lib/md043.mjs +72 -0
  130. package/packages/config-markdownlint/node_modules/markdownlint/lib/md044.mjs +110 -0
  131. package/packages/config-markdownlint/node_modules/markdownlint/lib/md045.mjs +61 -0
  132. package/packages/config-markdownlint/node_modules/markdownlint/lib/md046.mjs +31 -0
  133. package/packages/config-markdownlint/node_modules/markdownlint/lib/md047.mjs +28 -0
  134. package/packages/config-markdownlint/node_modules/markdownlint/lib/md048.mjs +47 -0
  135. package/packages/config-markdownlint/node_modules/markdownlint/lib/md049-md050.mjs +115 -0
  136. package/packages/config-markdownlint/node_modules/markdownlint/lib/md051.mjs +173 -0
  137. package/packages/config-markdownlint/node_modules/markdownlint/lib/md052.mjs +40 -0
  138. package/packages/config-markdownlint/node_modules/markdownlint/lib/md053.mjs +60 -0
  139. package/packages/config-markdownlint/node_modules/markdownlint/lib/md054.mjs +122 -0
  140. package/packages/config-markdownlint/node_modules/markdownlint/lib/md055.mjs +72 -0
  141. package/packages/config-markdownlint/node_modules/markdownlint/lib/md056.mjs +50 -0
  142. package/packages/config-markdownlint/node_modules/markdownlint/lib/md058.mjs +57 -0
  143. package/packages/config-markdownlint/node_modules/markdownlint/lib/md059.mjs +71 -0
  144. package/packages/config-markdownlint/node_modules/markdownlint/lib/md060.mjs +209 -0
  145. package/packages/config-markdownlint/node_modules/markdownlint/lib/micromark-parse.mjs +337 -0
  146. package/packages/config-markdownlint/node_modules/markdownlint/lib/micromark-types.d.mts +11 -0
  147. package/packages/config-markdownlint/node_modules/markdownlint/lib/node-imports-browser.mjs +22 -0
  148. package/packages/config-markdownlint/node_modules/markdownlint/lib/node-imports-node.mjs +11 -0
  149. package/packages/config-markdownlint/node_modules/markdownlint/lib/parse-configuration.mjs +47 -0
  150. package/packages/config-markdownlint/node_modules/markdownlint/lib/resolve-module.cjs +52 -0
  151. package/packages/config-markdownlint/node_modules/markdownlint/lib/resolve-module.d.cts +34 -0
  152. package/packages/config-markdownlint/node_modules/markdownlint/lib/rules.mjs +122 -0
  153. package/packages/config-markdownlint/node_modules/markdownlint/lib/types.d.mts +13 -0
  154. package/packages/config-markdownlint/node_modules/markdownlint/package.json +120 -0
  155. package/packages/config-markdownlint/node_modules/markdownlint/schema/.markdownlint.jsonc +349 -0
  156. package/packages/config-markdownlint/node_modules/markdownlint/schema/.markdownlint.yaml +310 -0
  157. package/packages/config-markdownlint/node_modules/markdownlint/schema/ValidatingConfiguration.md +26 -0
  158. package/packages/config-markdownlint/node_modules/markdownlint/schema/markdownlint-config-schema-strict.json +5138 -0
  159. package/packages/config-markdownlint/node_modules/markdownlint/schema/markdownlint-config-schema.json +5143 -0
  160. package/packages/config-markdownlint/node_modules/markdownlint/style/all.json +5 -0
  161. package/packages/config-markdownlint/node_modules/markdownlint/style/cirosantilli.json +22 -0
  162. package/packages/config-markdownlint/node_modules/markdownlint/style/prettier.json +27 -0
  163. package/packages/config-markdownlint/node_modules/markdownlint/style/relaxed.json +12 -0
  164. package/packages/config-markdownlint/node_modules/string-width/index.d.ts +39 -0
  165. package/packages/config-markdownlint/node_modules/string-width/index.js +203 -0
  166. package/packages/config-markdownlint/node_modules/string-width/license +9 -0
  167. package/packages/config-markdownlint/node_modules/string-width/package.json +65 -0
  168. package/packages/config-markdownlint/node_modules/string-width/readme.md +66 -0
  169. package/packages/config-markdownlint/node_modules/strip-ansi/index.d.ts +15 -0
  170. package/packages/config-markdownlint/node_modules/strip-ansi/index.js +19 -0
  171. package/packages/config-markdownlint/node_modules/strip-ansi/license +9 -0
  172. package/packages/config-markdownlint/node_modules/strip-ansi/package.json +59 -0
  173. package/packages/config-markdownlint/node_modules/strip-ansi/readme.md +37 -0
  174. package/packages/config-markdownlint/package.json +2 -2
  175. package/packages/config-stylelint/package.json +2 -2
  176. package/packages/config-stylelint/plugins/scss.js +1 -1
  177. package/packages/config-stylelint/plugins/selector-no-empty.js +1 -1
@@ -0,0 +1,47 @@
1
+ // @ts-check
2
+
3
+ import { addErrorContext } from "../helpers/helpers.cjs";
4
+ import { filterByTypesCached } from "./cache.mjs";
5
+
6
+ const dollarCommandRe = /^(\s*)(\$\s+)/;
7
+
8
+ /** @type {import("markdownlint").Rule} */
9
+ export default {
10
+ "names": [ "MD014", "commands-show-output" ],
11
+ "description": "Dollar signs used before commands without showing output",
12
+ "tags": [ "code" ],
13
+ "parser": "micromark",
14
+ "function": function MD014(params, onError) {
15
+ for (const codeBlock of filterByTypesCached([ "codeFenced", "codeIndented" ])) {
16
+ const codeFlowValues = codeBlock.children.filter((child) => child.type === "codeFlowValue");
17
+ const dollarMatches = codeFlowValues
18
+ .map((codeFlowValue) => ({
19
+ "result": codeFlowValue.text.match(dollarCommandRe),
20
+ "startColumn": codeFlowValue.startColumn,
21
+ "startLine": codeFlowValue.startLine,
22
+ "text": codeFlowValue.text
23
+ }))
24
+ .filter((dollarMatch) => dollarMatch.result);
25
+ if (dollarMatches.length === codeFlowValues.length) {
26
+ for (const dollarMatch of dollarMatches) {
27
+ // @ts-ignore
28
+ const column = dollarMatch.startColumn + dollarMatch.result[1].length;
29
+ // @ts-ignore
30
+ const length = dollarMatch.result[2].length;
31
+ addErrorContext(
32
+ onError,
33
+ dollarMatch.startLine,
34
+ dollarMatch.text,
35
+ undefined,
36
+ undefined,
37
+ [ column, length ],
38
+ {
39
+ "editColumn": column,
40
+ "deleteCount": length
41
+ }
42
+ );
43
+ }
44
+ }
45
+ }
46
+ }
47
+ };
@@ -0,0 +1,43 @@
1
+ // @ts-check
2
+
3
+ import { addErrorContext } from "../helpers/helpers.cjs";
4
+ import { addRangeToSet } from "../helpers/micromark-helpers.cjs";
5
+ import { filterByTypesCached } from "./cache.mjs";
6
+
7
+ /** @type {import("markdownlint").Rule} */
8
+ export default {
9
+ "names": [ "MD018", "no-missing-space-atx" ],
10
+ "description": "No space after hash on atx style heading",
11
+ "tags": [ "headings", "atx", "spaces" ],
12
+ "parser": "micromark",
13
+ "function": function MD018(params, onError) {
14
+ const { lines } = params;
15
+ const ignoreBlockLineNumbers = new Set();
16
+ for (const ignoreBlock of filterByTypesCached([ "codeFenced", "codeIndented", "htmlFlow" ])) {
17
+ addRangeToSet(ignoreBlockLineNumbers, ignoreBlock.startLine, ignoreBlock.endLine);
18
+ }
19
+ for (const [ lineIndex, line ] of lines.entries()) {
20
+ if (
21
+ !ignoreBlockLineNumbers.has(lineIndex + 1) &&
22
+ /^#+[^# \t]/.test(line) &&
23
+ !/#\s*$/.test(line) &&
24
+ !line.startsWith("#️⃣")
25
+ ) {
26
+ // @ts-ignore
27
+ const hashCount = /^#+/.exec(line)[0].length;
28
+ addErrorContext(
29
+ onError,
30
+ lineIndex + 1,
31
+ line.trim(),
32
+ undefined,
33
+ undefined,
34
+ [ 1, hashCount + 1 ],
35
+ {
36
+ "editColumn": hashCount + 1,
37
+ "insertText": " "
38
+ }
39
+ );
40
+ }
41
+ }
42
+ }
43
+ };
@@ -0,0 +1,77 @@
1
+ // @ts-check
2
+
3
+ import { addErrorContext } from "../helpers/helpers.cjs";
4
+ import { getHeadingStyle } from "../helpers/micromark-helpers.cjs";
5
+ import { filterByTypesCached } from "./cache.mjs";
6
+
7
+ /**
8
+ * Validate heading sequence and whitespace length at start or end.
9
+ *
10
+ * @param {import("markdownlint").RuleOnError} onError Error-reporting callback.
11
+ * @param {import("markdownlint").MicromarkToken} heading ATX heading token.
12
+ * @param {number} delta Direction to scan.
13
+ * @returns {void}
14
+ */
15
+ function validateHeadingSpaces(onError, heading, delta) {
16
+ const { children, startLine, text } = heading;
17
+ let index = (delta > 0) ? 0 : (children.length - 1);
18
+ while (
19
+ children[index] &&
20
+ (children[index].type !== "atxHeadingSequence")
21
+ ) {
22
+ index += delta;
23
+ }
24
+ const headingSequence = children[index];
25
+ const whitespace = children[index + delta];
26
+ if (
27
+ (headingSequence?.type === "atxHeadingSequence") &&
28
+ (whitespace?.type === "whitespace") &&
29
+ (whitespace.text.length > 1)
30
+ ) {
31
+ const column = whitespace.startColumn + 1;
32
+ const length = whitespace.endColumn - column;
33
+ addErrorContext(
34
+ onError,
35
+ startLine,
36
+ text.trim(),
37
+ delta > 0,
38
+ delta < 0,
39
+ [ column, length ],
40
+ {
41
+ "editColumn": column,
42
+ "deleteCount": length
43
+ }
44
+ );
45
+ }
46
+ }
47
+
48
+ /** @type {import("markdownlint").Rule[]} */
49
+ export default [
50
+ {
51
+ "names": [ "MD019", "no-multiple-space-atx" ],
52
+ "description": "Multiple spaces after hash on atx style heading",
53
+ "tags": [ "headings", "atx", "spaces" ],
54
+ "parser": "micromark",
55
+ "function": function MD019(params, onError) {
56
+ const atxHeadings = filterByTypesCached([ "atxHeading" ])
57
+ .filter((heading) => getHeadingStyle(heading) === "atx");
58
+ for (const atxHeading of atxHeadings) {
59
+ validateHeadingSpaces(onError, atxHeading, 1);
60
+ }
61
+ }
62
+ },
63
+ {
64
+ "names": [ "MD021", "no-multiple-space-closed-atx" ],
65
+ "description": "Multiple spaces inside hashes on closed atx style heading",
66
+ "tags": [ "headings", "atx_closed", "spaces" ],
67
+ "parser": "micromark",
68
+ "function": function MD021(params, onError) {
69
+ const atxClosedHeadings = filterByTypesCached([ "atxHeading" ])
70
+ .filter((heading) => getHeadingStyle(heading) === "atx_closed");
71
+ for (const atxClosedHeading of atxClosedHeadings) {
72
+ validateHeadingSpaces(onError, atxClosedHeading, 1);
73
+ validateHeadingSpaces(onError, atxClosedHeading, -1);
74
+ }
75
+ }
76
+ }
77
+ ];
@@ -0,0 +1,68 @@
1
+ // @ts-check
2
+
3
+ import { addErrorContext } from "../helpers/helpers.cjs";
4
+ import { addRangeToSet } from "../helpers/micromark-helpers.cjs";
5
+ import { filterByTypesCached } from "./cache.mjs";
6
+
7
+ /** @type {import("markdownlint").Rule} */
8
+ export default {
9
+ "names": [ "MD020", "no-missing-space-closed-atx" ],
10
+ "description": "No space inside hashes on closed atx style heading",
11
+ "tags": [ "headings", "atx_closed", "spaces" ],
12
+ "parser": "micromark",
13
+ "function": function MD020(params, onError) {
14
+ const { lines } = params;
15
+ const ignoreBlockLineNumbers = new Set();
16
+ for (const ignoreBlock of filterByTypesCached([ "codeFenced", "codeIndented", "htmlFlow" ])) {
17
+ addRangeToSet(ignoreBlockLineNumbers, ignoreBlock.startLine, ignoreBlock.endLine);
18
+ }
19
+ for (const [ lineIndex, line ] of lines.entries()) {
20
+ if (!ignoreBlockLineNumbers.has(lineIndex + 1)) {
21
+ const match =
22
+ /^(#+)([ \t]*)([^# \t\\]|[^# \t][^#]*?[^# \t\\])([ \t]*)((?:\\#)?)(#+)(\s*)$/.exec(line);
23
+ if (match) {
24
+ const [
25
+ ,
26
+ leftHash,
27
+ { "length": leftSpaceLength },
28
+ content,
29
+ { "length": rightSpaceLength },
30
+ rightEscape,
31
+ rightHash,
32
+ { "length": trailSpaceLength }
33
+ ] = match;
34
+ const leftHashLength = leftHash.length;
35
+ const rightHashLength = rightHash.length;
36
+ const left = !leftSpaceLength;
37
+ const right = !rightSpaceLength || !!rightEscape;
38
+ const rightEscapeReplacement = rightEscape ? `${rightEscape} ` : "";
39
+ if (left || right) {
40
+ const range = left ?
41
+ [
42
+ 1,
43
+ leftHashLength + 1
44
+ ] :
45
+ [
46
+ line.length - trailSpaceLength - rightHashLength,
47
+ rightHashLength + 1
48
+ ];
49
+ addErrorContext(
50
+ onError,
51
+ lineIndex + 1,
52
+ line.trim(),
53
+ left,
54
+ right,
55
+ range,
56
+ {
57
+ "editColumn": 1,
58
+ "deleteCount": line.length,
59
+ "insertText":
60
+ `${leftHash} ${content} ${rightEscapeReplacement}${rightHash}`
61
+ }
62
+ );
63
+ }
64
+ }
65
+ }
66
+ }
67
+ }
68
+ };
@@ -0,0 +1,103 @@
1
+ // @ts-check
2
+
3
+ import { addErrorDetailIf, isBlankLine } from "../helpers/helpers.cjs";
4
+ import { getBlockQuotePrefixText, getHeadingLevel } from "../helpers/micromark-helpers.cjs";
5
+ import { filterByTypesCached } from "./cache.mjs";
6
+
7
+ /** @typedef {import("markdownlint").MicromarkToken} MicromarkToken */
8
+
9
+ const defaultLines = 1;
10
+
11
+ // eslint-disable-next-line jsdoc/reject-any-type
12
+ const getLinesFunction = (/** @type {any} */ linesParam) => {
13
+ if (Array.isArray(linesParam)) {
14
+ const linesArray = new Array(6).fill(defaultLines);
15
+ for (const [ index, value ] of [ ...linesParam.entries() ].slice(0, 6)) {
16
+ linesArray[index] = value;
17
+ }
18
+ return (/** @type {MicromarkToken} */ heading) => linesArray[getHeadingLevel(heading) - 1];
19
+ }
20
+ // Coerce linesParam to a number
21
+ const lines = (linesParam === undefined) ? defaultLines : Number(linesParam);
22
+ return () => lines;
23
+ };
24
+
25
+ const getLine = (/** @type {readonly string[]} */ lines, /** @type {number} */ index, /** @type {readonly string[]} */ frontMatterLines, /** @type {boolean} */ includeFrontMatter) => {
26
+ if ((index >= 0) && (index < lines.length)) {
27
+ return lines[index];
28
+ }
29
+ if (includeFrontMatter && (frontMatterLines.length > 0) && (index < 0) && (index >= -frontMatterLines.length)) {
30
+ return frontMatterLines[frontMatterLines.length + index];
31
+ }
32
+ return "";
33
+ };
34
+
35
+ /** @type {import("markdownlint").Rule} */
36
+ export default {
37
+ "names": [ "MD022", "blanks-around-headings" ],
38
+ "description": "Headings should be surrounded by blank lines",
39
+ "tags": [ "headings", "blank_lines" ],
40
+ "parser": "micromark",
41
+ "function": function MD022(params, onError) {
42
+ const getLinesAbove = getLinesFunction(params.config.lines_above);
43
+ const getLinesBelow = getLinesFunction(params.config.lines_below);
44
+ const includeFrontMatter = !!params.config.include_front_matter;
45
+ const { lines, frontMatterLines } = params;
46
+ const blockQuotePrefixes = filterByTypesCached([ "blockQuotePrefix", "linePrefix" ]);
47
+ for (const heading of filterByTypesCached([ "atxHeading", "setextHeading" ])) {
48
+ const { startLine, endLine } = heading;
49
+ const line = lines[startLine - 1].trim();
50
+
51
+ // Check lines above
52
+ const linesAbove = getLinesAbove(heading);
53
+ if (linesAbove >= 0) {
54
+ let actualAbove = 0;
55
+ for (let i = 0; (i < linesAbove) && isBlankLine(getLine(lines, startLine - 2 - i, frontMatterLines, includeFrontMatter)); i++) {
56
+ actualAbove++;
57
+ }
58
+ addErrorDetailIf(
59
+ onError,
60
+ startLine,
61
+ linesAbove,
62
+ actualAbove,
63
+ "Above",
64
+ line,
65
+ undefined,
66
+ {
67
+ "insertText": getBlockQuotePrefixText(
68
+ blockQuotePrefixes,
69
+ startLine - 1,
70
+ linesAbove - actualAbove
71
+ )
72
+ }
73
+ );
74
+ }
75
+
76
+ // Check lines below
77
+ const linesBelow = getLinesBelow(heading);
78
+ if (linesBelow >= 0) {
79
+ let actualBelow = 0;
80
+ for (let i = 0; (i < linesBelow) && isBlankLine(getLine(lines, endLine + i, frontMatterLines, false)); i++) {
81
+ actualBelow++;
82
+ }
83
+ addErrorDetailIf(
84
+ onError,
85
+ startLine,
86
+ linesBelow,
87
+ actualBelow,
88
+ "Below",
89
+ line,
90
+ undefined,
91
+ {
92
+ "lineNumber": endLine + 1,
93
+ "insertText": getBlockQuotePrefixText(
94
+ blockQuotePrefixes,
95
+ endLine + 1,
96
+ linesBelow - actualBelow
97
+ )
98
+ }
99
+ );
100
+ }
101
+ }
102
+ }
103
+ };
@@ -0,0 +1,37 @@
1
+ // @ts-check
2
+
3
+ import { addErrorContext } from "../helpers/helpers.cjs";
4
+ import { filterByTypesCached } from "./cache.mjs";
5
+
6
+ /** @type {import("markdownlint").Rule} */
7
+ export default {
8
+ "names": [ "MD023", "heading-start-left" ],
9
+ "description": "Headings must start at the beginning of the line",
10
+ "tags": [ "headings", "spaces" ],
11
+ "parser": "micromark",
12
+ "function": function MD023(params, onError) {
13
+ const headings = filterByTypesCached([ "atxHeading", "linePrefix", "setextHeading" ]);
14
+ for (let i = 0; i < headings.length - 1; i++) {
15
+ if (
16
+ (headings[i].type === "linePrefix") &&
17
+ (headings[i + 1].type !== "linePrefix") &&
18
+ (headings[i].startLine === headings[i + 1].startLine)
19
+ ) {
20
+ const { endColumn, startColumn, startLine } = headings[i];
21
+ const length = endColumn - startColumn;
22
+ addErrorContext(
23
+ onError,
24
+ startLine,
25
+ params.lines[startLine - 1],
26
+ true,
27
+ false,
28
+ [ startColumn, length ],
29
+ {
30
+ "editColumn": startColumn,
31
+ "deleteCount": length
32
+ }
33
+ );
34
+ }
35
+ }
36
+ }
37
+ };
@@ -0,0 +1,45 @@
1
+ // @ts-check
2
+
3
+ import { addErrorContext } 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": [ "MD024", "no-duplicate-heading" ],
10
+ "description": "Multiple headings with the same content",
11
+ "tags": [ "headings" ],
12
+ "parser": "micromark",
13
+ "function": function MD024(params, onError) {
14
+ const siblingsOnly = !!params.config.siblings_only || false;
15
+ const knownContents = [ null, [] ];
16
+ let lastLevel = 1;
17
+ let knownContent = knownContents[lastLevel];
18
+ for (const heading of filterByTypesCached([ "atxHeading", "setextHeading" ])) {
19
+ const headingText = getHeadingText(heading);
20
+ if (siblingsOnly) {
21
+ const newLevel = getHeadingLevel(heading);
22
+ while (lastLevel < newLevel) {
23
+ lastLevel++;
24
+ knownContents[lastLevel] = [];
25
+ }
26
+ while (lastLevel > newLevel) {
27
+ knownContents[lastLevel] = [];
28
+ lastLevel--;
29
+ }
30
+ knownContent = knownContents[newLevel];
31
+ }
32
+ // @ts-ignore
33
+ if (knownContent.includes(headingText)) {
34
+ addErrorContext(
35
+ onError,
36
+ heading.startLine,
37
+ headingText.trim()
38
+ );
39
+ } else {
40
+ // @ts-ignore
41
+ knownContent.push(headingText);
42
+ }
43
+ }
44
+ }
45
+ };
@@ -0,0 +1,45 @@
1
+ // @ts-check
2
+
3
+ import { addErrorContext, frontMatterHasTitle } from "../helpers/helpers.cjs";
4
+ import { getHeadingLevel, getHeadingText, isDocfxTab, isHtmlFlowComment, nonContentTokens } from "../helpers/micromark-helpers.cjs";
5
+ import { filterByTypesCached } from "./cache.mjs";
6
+
7
+ /** @type {import("markdownlint").Rule} */
8
+ export default {
9
+ "names": [ "MD025", "single-title", "single-h1" ],
10
+ "description": "Multiple top-level headings in the same document",
11
+ "tags": [ "headings" ],
12
+ "parser": "micromark",
13
+ "function": function MD025(params, onError) {
14
+ const level = Number(params.config.level || 1);
15
+ const { tokens } = params.parsers.micromark;
16
+ const matchingHeadings = filterByTypesCached([ "atxHeading", "setextHeading" ])
17
+ .filter((heading) => (level === getHeadingLevel(heading)) && !isDocfxTab(heading));
18
+ if (matchingHeadings.length > 0) {
19
+ const foundFrontMatterTitle =
20
+ frontMatterHasTitle(
21
+ params.frontMatterLines,
22
+ params.config.front_matter_title
23
+ );
24
+ // Front matter title counts as a top-level heading if present
25
+ let hasTopLevelHeading = foundFrontMatterTitle;
26
+ if (!hasTopLevelHeading) {
27
+ // Check if the first matching heading is a top-level heading
28
+ const previousTokens = tokens.slice(0, tokens.indexOf(matchingHeadings[0]));
29
+ hasTopLevelHeading = previousTokens.every(
30
+ (token) => nonContentTokens.has(token.type) || isHtmlFlowComment(token)
31
+ );
32
+ }
33
+ if (hasTopLevelHeading) {
34
+ // All other matching headings are violations
35
+ for (const heading of matchingHeadings.slice(foundFrontMatterTitle ? 0 : 1)) {
36
+ addErrorContext(
37
+ onError,
38
+ heading.startLine,
39
+ getHeadingText(heading)
40
+ );
41
+ }
42
+ }
43
+ }
44
+ }
45
+ };
@@ -0,0 +1,46 @@
1
+ // @ts-check
2
+
3
+ import { addError, allPunctuationNoQuestion, endOfLineGemojiCodeRe,
4
+ endOfLineHtmlEntityRe, escapeForRegExp } from "../helpers/helpers.cjs";
5
+ import { filterByTypesCached } from "./cache.mjs";
6
+
7
+ /** @type {import("markdownlint").Rule} */
8
+ export default {
9
+ "names": [ "MD026", "no-trailing-punctuation" ],
10
+ "description": "Trailing punctuation in heading",
11
+ "tags": [ "headings" ],
12
+ "parser": "micromark",
13
+ "function": function MD026(params, onError) {
14
+ let punctuation = params.config.punctuation;
15
+ punctuation = String(
16
+ (punctuation === undefined) ? allPunctuationNoQuestion : punctuation
17
+ );
18
+ const trailingPunctuationRe =
19
+ new RegExp("\\s*[" + escapeForRegExp(punctuation) + "]+$");
20
+ const headings = filterByTypesCached([ "atxHeadingText", "setextHeadingText" ]);
21
+ for (const heading of headings) {
22
+ const { endColumn, endLine, text } = heading;
23
+ const match = trailingPunctuationRe.exec(text);
24
+ if (
25
+ match &&
26
+ !endOfLineHtmlEntityRe.test(text) &&
27
+ !endOfLineGemojiCodeRe.test(text)
28
+ ) {
29
+ const fullMatch = match[0];
30
+ const length = fullMatch.length;
31
+ const column = endColumn - length;
32
+ addError(
33
+ onError,
34
+ endLine,
35
+ `Punctuation: '${fullMatch}'`,
36
+ undefined,
37
+ [ column, length ],
38
+ {
39
+ "editColumn": column,
40
+ "deleteCount": length
41
+ }
42
+ );
43
+ }
44
+ }
45
+ }
46
+ };
@@ -0,0 +1,50 @@
1
+ // @ts-check
2
+
3
+ import { addErrorContext } from "../helpers/helpers.cjs";
4
+ import { getParentOfType } from "../helpers/micromark-helpers.cjs";
5
+ import { filterByTypesCached } from "./cache.mjs";
6
+
7
+ /** @type {import("../helpers/micromark-helpers.cjs").TokenType[]} */
8
+ const listTypes = [ "listOrdered", "listUnordered" ];
9
+
10
+ /** @type {import("markdownlint").Rule} */
11
+ export default {
12
+ "names": [ "MD027", "no-multiple-space-blockquote" ],
13
+ "description": "Multiple spaces after blockquote symbol",
14
+ "tags": [ "blockquote", "whitespace", "indentation" ],
15
+ "parser": "micromark",
16
+ "function": function MD027(params, onError) {
17
+ const listItems = params.config.list_items;
18
+ const includeListItems = (listItems === undefined) ? true : !!listItems;
19
+ const { tokens } = params.parsers.micromark;
20
+ for (const token of filterByTypesCached([ "linePrefix" ])) {
21
+ const parent = token.parent;
22
+ const codeIndented = parent?.type === "codeIndented";
23
+ const siblings = parent?.children || tokens;
24
+ if (
25
+ !codeIndented &&
26
+ (siblings[siblings.indexOf(token) - 1]?.type === "blockQuotePrefix") &&
27
+ (includeListItems || (
28
+ !listTypes.includes(siblings[siblings.indexOf(token) + 1]?.type) &&
29
+ !getParentOfType(token, listTypes)
30
+ ))
31
+ ) {
32
+ const { startColumn, startLine, text } = token;
33
+ const { length } = text;
34
+ const line = params.lines[startLine - 1];
35
+ addErrorContext(
36
+ onError,
37
+ startLine,
38
+ line,
39
+ undefined,
40
+ undefined,
41
+ [ startColumn, length ],
42
+ {
43
+ "editColumn": startColumn,
44
+ "deleteCount": length
45
+ }
46
+ );
47
+ }
48
+ }
49
+ }
50
+ };
@@ -0,0 +1,39 @@
1
+ // @ts-check
2
+
3
+ import { addError } from "../helpers/helpers.cjs";
4
+ import { filterByTypesCached } from "./cache.mjs";
5
+
6
+ const ignoreTypes = new Set([ "lineEnding", "listItemIndent", "linePrefix" ]);
7
+
8
+ /** @type {import("markdownlint").Rule} */
9
+ export default {
10
+ "names": [ "MD028", "no-blanks-blockquote" ],
11
+ "description": "Blank line inside blockquote",
12
+ "tags": [ "blockquote", "whitespace" ],
13
+ "parser": "micromark",
14
+ "function": function MD028(params, onError) {
15
+ for (const token of filterByTypesCached([ "blockQuote" ])) {
16
+ const errorLineNumbers = [];
17
+ const siblings = token.parent?.children || params.parsers.micromark.tokens;
18
+ for (let i = siblings.indexOf(token) + 1; i < siblings.length; i++) {
19
+ const sibling = siblings[i];
20
+ const { startLine, type } = sibling;
21
+ if (type === "lineEndingBlank") {
22
+ // Possible blank between blockquotes
23
+ errorLineNumbers.push(startLine);
24
+ } else if (ignoreTypes.has(type)) {
25
+ // Ignore invisible formatting
26
+ } else if (type === "blockQuote") {
27
+ // Blockquote followed by blockquote
28
+ for (const lineNumber of errorLineNumbers) {
29
+ addError(onError, lineNumber);
30
+ }
31
+ break;
32
+ } else {
33
+ // Blockquote not followed by blockquote
34
+ break;
35
+ }
36
+ }
37
+ }
38
+ }
39
+ };