@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,47 +0,0 @@
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
- };
@@ -1,43 +0,0 @@
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
- };
@@ -1,77 +0,0 @@
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
- ];
@@ -1,68 +0,0 @@
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
- };
@@ -1,103 +0,0 @@
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
- };
@@ -1,37 +0,0 @@
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
- };
@@ -1,45 +0,0 @@
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
- };
@@ -1,45 +0,0 @@
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
- };
@@ -1,46 +0,0 @@
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
- };
@@ -1,50 +0,0 @@
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
- };
@@ -1,39 +0,0 @@
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
- };