@alexlit/lint-kit 107.0.0 → 107.2.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 (193) hide show
  1. package/package.json +1 -11
  2. package/packages/config-commitlint/package.json +2 -2
  3. package/packages/config-eslint/package.json +4 -4
  4. package/packages/config-hooks/package.json +3 -3
  5. package/packages/config-markdownlint/node_modules/markdown-it/LICENSE +22 -0
  6. package/packages/config-markdownlint/node_modules/markdown-it/README.md +309 -0
  7. package/packages/config-markdownlint/node_modules/markdown-it/bin/markdown-it.js +117 -0
  8. package/packages/config-markdownlint/node_modules/markdown-it/dist/markdown-it.js +8441 -0
  9. package/packages/config-markdownlint/node_modules/markdown-it/dist/markdown-it.min.js +3 -0
  10. package/packages/config-markdownlint/node_modules/markdown-it/index.js +4 -0
  11. package/packages/config-markdownlint/node_modules/markdown-it/lib/common/entities.js +6 -0
  12. package/packages/config-markdownlint/node_modules/markdown-it/lib/common/html_blocks.js +70 -0
  13. package/packages/config-markdownlint/node_modules/markdown-it/lib/common/html_re.js +28 -0
  14. package/packages/config-markdownlint/node_modules/markdown-it/lib/common/utils.js +317 -0
  15. package/packages/config-markdownlint/node_modules/markdown-it/lib/helpers/index.js +7 -0
  16. package/packages/config-markdownlint/node_modules/markdown-it/lib/helpers/parse_link_destination.js +80 -0
  17. package/packages/config-markdownlint/node_modules/markdown-it/lib/helpers/parse_link_label.js +48 -0
  18. package/packages/config-markdownlint/node_modules/markdown-it/lib/helpers/parse_link_title.js +55 -0
  19. package/packages/config-markdownlint/node_modules/markdown-it/lib/index.js +582 -0
  20. package/packages/config-markdownlint/node_modules/markdown-it/lib/parser_block.js +131 -0
  21. package/packages/config-markdownlint/node_modules/markdown-it/lib/parser_core.js +61 -0
  22. package/packages/config-markdownlint/node_modules/markdown-it/lib/parser_inline.js +192 -0
  23. package/packages/config-markdownlint/node_modules/markdown-it/lib/presets/commonmark.js +81 -0
  24. package/packages/config-markdownlint/node_modules/markdown-it/lib/presets/default.js +41 -0
  25. package/packages/config-markdownlint/node_modules/markdown-it/lib/presets/zero.js +63 -0
  26. package/packages/config-markdownlint/node_modules/markdown-it/lib/renderer.js +341 -0
  27. package/packages/config-markdownlint/node_modules/markdown-it/lib/ruler.js +352 -0
  28. package/packages/config-markdownlint/node_modules/markdown-it/lib/rules_block/blockquote.js +226 -0
  29. package/packages/config-markdownlint/node_modules/markdown-it/lib/rules_block/code.js +34 -0
  30. package/packages/config-markdownlint/node_modules/markdown-it/lib/rules_block/fence.js +98 -0
  31. package/packages/config-markdownlint/node_modules/markdown-it/lib/rules_block/heading.js +55 -0
  32. package/packages/config-markdownlint/node_modules/markdown-it/lib/rules_block/hr.js +45 -0
  33. package/packages/config-markdownlint/node_modules/markdown-it/lib/rules_block/html_block.js +74 -0
  34. package/packages/config-markdownlint/node_modules/markdown-it/lib/rules_block/lheading.js +83 -0
  35. package/packages/config-markdownlint/node_modules/markdown-it/lib/rules_block/list.js +362 -0
  36. package/packages/config-markdownlint/node_modules/markdown-it/lib/rules_block/paragraph.js +51 -0
  37. package/packages/config-markdownlint/node_modules/markdown-it/lib/rules_block/reference.js +198 -0
  38. package/packages/config-markdownlint/node_modules/markdown-it/lib/rules_block/state_block.js +231 -0
  39. package/packages/config-markdownlint/node_modules/markdown-it/lib/rules_block/table.js +221 -0
  40. package/packages/config-markdownlint/node_modules/markdown-it/lib/rules_core/block.js +16 -0
  41. package/packages/config-markdownlint/node_modules/markdown-it/lib/rules_core/inline.js +13 -0
  42. package/packages/config-markdownlint/node_modules/markdown-it/lib/rules_core/linkify.js +142 -0
  43. package/packages/config-markdownlint/node_modules/markdown-it/lib/rules_core/normalize.js +21 -0
  44. package/packages/config-markdownlint/node_modules/markdown-it/lib/rules_core/replacements.js +105 -0
  45. package/packages/config-markdownlint/node_modules/markdown-it/lib/rules_core/smartquotes.js +201 -0
  46. package/packages/config-markdownlint/node_modules/markdown-it/lib/rules_core/state_core.js +20 -0
  47. package/packages/config-markdownlint/node_modules/markdown-it/lib/rules_core/text_join.js +45 -0
  48. package/packages/config-markdownlint/node_modules/markdown-it/lib/rules_inline/autolink.js +76 -0
  49. package/packages/config-markdownlint/node_modules/markdown-it/lib/rules_inline/backticks.js +63 -0
  50. package/packages/config-markdownlint/node_modules/markdown-it/lib/rules_inline/balance_pairs.js +130 -0
  51. package/packages/config-markdownlint/node_modules/markdown-it/lib/rules_inline/emphasis.js +130 -0
  52. package/packages/config-markdownlint/node_modules/markdown-it/lib/rules_inline/entity.js +55 -0
  53. package/packages/config-markdownlint/node_modules/markdown-it/lib/rules_inline/escape.js +71 -0
  54. package/packages/config-markdownlint/node_modules/markdown-it/lib/rules_inline/fragments_join.js +41 -0
  55. package/packages/config-markdownlint/node_modules/markdown-it/lib/rules_inline/html_inline.js +58 -0
  56. package/packages/config-markdownlint/node_modules/markdown-it/lib/rules_inline/image.js +152 -0
  57. package/packages/config-markdownlint/node_modules/markdown-it/lib/rules_inline/link.js +150 -0
  58. package/packages/config-markdownlint/node_modules/markdown-it/lib/rules_inline/linkify.js +62 -0
  59. package/packages/config-markdownlint/node_modules/markdown-it/lib/rules_inline/newline.js +46 -0
  60. package/packages/config-markdownlint/node_modules/markdown-it/lib/rules_inline/state_inline.js +158 -0
  61. package/packages/config-markdownlint/node_modules/markdown-it/lib/rules_inline/strikethrough.js +130 -0
  62. package/packages/config-markdownlint/node_modules/markdown-it/lib/rules_inline/text.js +89 -0
  63. package/packages/config-markdownlint/node_modules/markdown-it/lib/token.js +201 -0
  64. package/packages/config-markdownlint/node_modules/markdown-it/package.json +87 -0
  65. package/packages/config-markdownlint/node_modules/markdownlint/CHANGELOG.md +428 -0
  66. package/packages/config-markdownlint/node_modules/markdownlint/CONTRIBUTING.md +92 -0
  67. package/packages/config-markdownlint/node_modules/markdownlint/LICENSE +21 -0
  68. package/packages/config-markdownlint/node_modules/markdownlint/README.md +1026 -0
  69. package/packages/config-markdownlint/node_modules/markdownlint/demo/markdownlint-browser.js +6814 -0
  70. package/packages/config-markdownlint/node_modules/markdownlint/doc/CustomRules.md +376 -0
  71. package/packages/config-markdownlint/node_modules/markdownlint/doc/Prettier.md +27 -0
  72. package/packages/config-markdownlint/node_modules/markdownlint/doc/ReleaseProcess.md +20 -0
  73. package/packages/config-markdownlint/node_modules/markdownlint/doc/Rules.md +2335 -0
  74. package/packages/config-markdownlint/node_modules/markdownlint/doc/md001.md +37 -0
  75. package/packages/config-markdownlint/node_modules/markdownlint/doc/md003.md +59 -0
  76. package/packages/config-markdownlint/node_modules/markdownlint/doc/md004.md +49 -0
  77. package/packages/config-markdownlint/node_modules/markdownlint/doc/md005.md +53 -0
  78. package/packages/config-markdownlint/node_modules/markdownlint/doc/md007.md +52 -0
  79. package/packages/config-markdownlint/node_modules/markdownlint/doc/md009.md +51 -0
  80. package/packages/config-markdownlint/node_modules/markdownlint/doc/md010.md +56 -0
  81. package/packages/config-markdownlint/node_modules/markdownlint/doc/md011.md +30 -0
  82. package/packages/config-markdownlint/node_modules/markdownlint/doc/md012.md +38 -0
  83. package/packages/config-markdownlint/node_modules/markdownlint/doc/md013.md +57 -0
  84. package/packages/config-markdownlint/node_modules/markdownlint/doc/md014.md +54 -0
  85. package/packages/config-markdownlint/node_modules/markdownlint/doc/md018.md +27 -0
  86. package/packages/config-markdownlint/node_modules/markdownlint/doc/md019.md +28 -0
  87. package/packages/config-markdownlint/node_modules/markdownlint/doc/md020.md +29 -0
  88. package/packages/config-markdownlint/node_modules/markdownlint/doc/md021.md +31 -0
  89. package/packages/config-markdownlint/node_modules/markdownlint/doc/md022.md +52 -0
  90. package/packages/config-markdownlint/node_modules/markdownlint/doc/md023.md +33 -0
  91. package/packages/config-markdownlint/node_modules/markdownlint/doc/md024.md +47 -0
  92. package/packages/config-markdownlint/node_modules/markdownlint/doc/md025.md +49 -0
  93. package/packages/config-markdownlint/node_modules/markdownlint/doc/md026.md +40 -0
  94. package/packages/config-markdownlint/node_modules/markdownlint/doc/md027.md +24 -0
  95. package/packages/config-markdownlint/node_modules/markdownlint/doc/md028.md +40 -0
  96. package/packages/config-markdownlint/node_modules/markdownlint/doc/md029.md +98 -0
  97. package/packages/config-markdownlint/node_modules/markdownlint/doc/md030.md +82 -0
  98. package/packages/config-markdownlint/node_modules/markdownlint/doc/md031.md +50 -0
  99. package/packages/config-markdownlint/node_modules/markdownlint/doc/md032.md +55 -0
  100. package/packages/config-markdownlint/node_modules/markdownlint/doc/md033.md +27 -0
  101. package/packages/config-markdownlint/node_modules/markdownlint/doc/md034.md +50 -0
  102. package/packages/config-markdownlint/node_modules/markdownlint/doc/md035.md +42 -0
  103. package/packages/config-markdownlint/node_modules/markdownlint/doc/md036.md +45 -0
  104. package/packages/config-markdownlint/node_modules/markdownlint/doc/md037.md +37 -0
  105. package/packages/config-markdownlint/node_modules/markdownlint/doc/md038.md +40 -0
  106. package/packages/config-markdownlint/node_modules/markdownlint/doc/md039.md +21 -0
  107. package/packages/config-markdownlint/node_modules/markdownlint/doc/md040.md +52 -0
  108. package/packages/config-markdownlint/node_modules/markdownlint/doc/md041.md +49 -0
  109. package/packages/config-markdownlint/node_modules/markdownlint/doc/md042.md +32 -0
  110. package/packages/config-markdownlint/node_modules/markdownlint/doc/md043.md +69 -0
  111. package/packages/config-markdownlint/node_modules/markdownlint/doc/md044.md +35 -0
  112. package/packages/config-markdownlint/node_modules/markdownlint/doc/md045.md +40 -0
  113. package/packages/config-markdownlint/node_modules/markdownlint/doc/md046.md +40 -0
  114. package/packages/config-markdownlint/node_modules/markdownlint/doc/md047.md +34 -0
  115. package/packages/config-markdownlint/node_modules/markdownlint/doc/md048.md +41 -0
  116. package/packages/config-markdownlint/node_modules/markdownlint/doc/md049.md +32 -0
  117. package/packages/config-markdownlint/node_modules/markdownlint/doc/md050.md +32 -0
  118. package/packages/config-markdownlint/node_modules/markdownlint/doc/md051.md +61 -0
  119. package/packages/config-markdownlint/node_modules/markdownlint/doc/md052.md +40 -0
  120. package/packages/config-markdownlint/node_modules/markdownlint/doc/md053.md +38 -0
  121. package/packages/config-markdownlint/node_modules/markdownlint/doc/md054.md +100 -0
  122. package/packages/config-markdownlint/node_modules/markdownlint/helpers/LICENSE +21 -0
  123. package/packages/config-markdownlint/node_modules/markdownlint/helpers/README.md +70 -0
  124. package/packages/config-markdownlint/node_modules/markdownlint/helpers/helpers.js +1025 -0
  125. package/packages/config-markdownlint/node_modules/markdownlint/helpers/micromark.cjs +426 -0
  126. package/packages/config-markdownlint/node_modules/markdownlint/helpers/package.json +26 -0
  127. package/packages/config-markdownlint/node_modules/markdownlint/helpers/shared.js +10 -0
  128. package/packages/config-markdownlint/node_modules/markdownlint/lib/cache.js +21 -0
  129. package/packages/config-markdownlint/node_modules/markdownlint/lib/configuration.d.ts +1152 -0
  130. package/packages/config-markdownlint/node_modules/markdownlint/lib/constants.js +14 -0
  131. package/packages/config-markdownlint/node_modules/markdownlint/lib/markdownlint.d.ts +406 -0
  132. package/packages/config-markdownlint/node_modules/markdownlint/lib/markdownlint.js +1476 -0
  133. package/packages/config-markdownlint/node_modules/markdownlint/lib/md001.js +22 -0
  134. package/packages/config-markdownlint/node_modules/markdownlint/lib/md003.js +42 -0
  135. package/packages/config-markdownlint/node_modules/markdownlint/lib/md004.js +76 -0
  136. package/packages/config-markdownlint/node_modules/markdownlint/lib/md005.js +73 -0
  137. package/packages/config-markdownlint/node_modules/markdownlint/lib/md007.js +86 -0
  138. package/packages/config-markdownlint/node_modules/markdownlint/lib/md009.js +86 -0
  139. package/packages/config-markdownlint/node_modules/markdownlint/lib/md010.js +60 -0
  140. package/packages/config-markdownlint/node_modules/markdownlint/lib/md011.js +46 -0
  141. package/packages/config-markdownlint/node_modules/markdownlint/lib/md012.js +32 -0
  142. package/packages/config-markdownlint/node_modules/markdownlint/lib/md013.js +96 -0
  143. package/packages/config-markdownlint/node_modules/markdownlint/lib/md014.js +53 -0
  144. package/packages/config-markdownlint/node_modules/markdownlint/lib/md018.js +34 -0
  145. package/packages/config-markdownlint/node_modules/markdownlint/lib/md019.js +39 -0
  146. package/packages/config-markdownlint/node_modules/markdownlint/lib/md020.js +62 -0
  147. package/packages/config-markdownlint/node_modules/markdownlint/lib/md021.js +62 -0
  148. package/packages/config-markdownlint/node_modules/markdownlint/lib/md022.js +108 -0
  149. package/packages/config-markdownlint/node_modules/markdownlint/lib/md023.js +38 -0
  150. package/packages/config-markdownlint/node_modules/markdownlint/lib/md024.js +38 -0
  151. package/packages/config-markdownlint/node_modules/markdownlint/lib/md025.js +32 -0
  152. package/packages/config-markdownlint/node_modules/markdownlint/lib/md026.js +50 -0
  153. package/packages/config-markdownlint/node_modules/markdownlint/lib/md027.js +56 -0
  154. package/packages/config-markdownlint/node_modules/markdownlint/lib/md028.js +30 -0
  155. package/packages/config-markdownlint/node_modules/markdownlint/lib/md029.js +67 -0
  156. package/packages/config-markdownlint/node_modules/markdownlint/lib/md030.js +61 -0
  157. package/packages/config-markdownlint/node_modules/markdownlint/lib/md031.js +40 -0
  158. package/packages/config-markdownlint/node_modules/markdownlint/lib/md032.js +78 -0
  159. package/packages/config-markdownlint/node_modules/markdownlint/lib/md033.js +39 -0
  160. package/packages/config-markdownlint/node_modules/markdownlint/lib/md034.js +79 -0
  161. package/packages/config-markdownlint/node_modules/markdownlint/lib/md035.js +24 -0
  162. package/packages/config-markdownlint/node_modules/markdownlint/lib/md036.js +56 -0
  163. package/packages/config-markdownlint/node_modules/markdownlint/lib/md037.js +91 -0
  164. package/packages/config-markdownlint/node_modules/markdownlint/lib/md038.js +97 -0
  165. package/packages/config-markdownlint/node_modules/markdownlint/lib/md039.js +67 -0
  166. package/packages/config-markdownlint/node_modules/markdownlint/lib/md040.js +37 -0
  167. package/packages/config-markdownlint/node_modules/markdownlint/lib/md041.js +42 -0
  168. package/packages/config-markdownlint/node_modules/markdownlint/lib/md042.js +49 -0
  169. package/packages/config-markdownlint/node_modules/markdownlint/lib/md043.js +64 -0
  170. package/packages/config-markdownlint/node_modules/markdownlint/lib/md044.js +107 -0
  171. package/packages/config-markdownlint/node_modules/markdownlint/lib/md045.js +60 -0
  172. package/packages/config-markdownlint/node_modules/markdownlint/lib/md046.js +33 -0
  173. package/packages/config-markdownlint/node_modules/markdownlint/lib/md047.js +28 -0
  174. package/packages/config-markdownlint/node_modules/markdownlint/lib/md048.js +30 -0
  175. package/packages/config-markdownlint/node_modules/markdownlint/lib/md049-md050.js +89 -0
  176. package/packages/config-markdownlint/node_modules/markdownlint/lib/md051.js +172 -0
  177. package/packages/config-markdownlint/node_modules/markdownlint/lib/md052.js +39 -0
  178. package/packages/config-markdownlint/node_modules/markdownlint/lib/md053.js +59 -0
  179. package/packages/config-markdownlint/node_modules/markdownlint/lib/md054.js +125 -0
  180. package/packages/config-markdownlint/node_modules/markdownlint/lib/rules.js +65 -0
  181. package/packages/config-markdownlint/node_modules/markdownlint/package.json +109 -0
  182. package/packages/config-markdownlint/node_modules/markdownlint/schema/.markdownlint.jsonc +297 -0
  183. package/packages/config-markdownlint/node_modules/markdownlint/schema/.markdownlint.yaml +266 -0
  184. package/packages/config-markdownlint/node_modules/markdownlint/schema/markdownlint-config-schema.json +1762 -0
  185. package/packages/config-markdownlint/node_modules/markdownlint/style/all.json +5 -0
  186. package/packages/config-markdownlint/node_modules/markdownlint/style/cirosantilli.json +22 -0
  187. package/packages/config-markdownlint/node_modules/markdownlint/style/prettier.json +26 -0
  188. package/packages/config-markdownlint/node_modules/markdownlint/style/relaxed.json +12 -0
  189. package/packages/config-markdownlint/package.json +3 -3
  190. package/packages/config-prettier/README.md +16 -0
  191. package/packages/config-prettier/package.json +4 -4
  192. package/packages/config-stylelint/package.json +2 -2
  193. package/scripts/semver.sh +6 -5
@@ -0,0 +1,22 @@
1
+ // @ts-check
2
+
3
+ "use strict";
4
+
5
+ const { addErrorDetailIf, filterTokens } = require("../helpers");
6
+
7
+ module.exports = {
8
+ "names": [ "MD001", "heading-increment" ],
9
+ "description": "Heading levels should only increment by one level at a time",
10
+ "tags": [ "headings" ],
11
+ "function": function MD001(params, onError) {
12
+ let prevLevel = 0;
13
+ filterTokens(params, "heading_open", function forToken(token) {
14
+ const level = Number.parseInt(token.tag.slice(1), 10);
15
+ if (prevLevel && (level > prevLevel)) {
16
+ addErrorDetailIf(onError, token.lineNumber,
17
+ "h" + (prevLevel + 1), "h" + level);
18
+ }
19
+ prevLevel = level;
20
+ });
21
+ }
22
+ };
@@ -0,0 +1,42 @@
1
+ // @ts-check
2
+
3
+ "use strict";
4
+
5
+ const { addErrorDetailIf, filterTokens, headingStyleFor } =
6
+ require("../helpers");
7
+
8
+ module.exports = {
9
+ "names": [ "MD003", "heading-style" ],
10
+ "description": "Heading style",
11
+ "tags": [ "headings" ],
12
+ "function": function MD003(params, onError) {
13
+ let style = String(params.config.style || "consistent");
14
+ filterTokens(params, "heading_open", function forToken(token) {
15
+ const styleForToken = headingStyleFor(token);
16
+ if (style === "consistent") {
17
+ style = styleForToken;
18
+ }
19
+ if (styleForToken !== style) {
20
+ const h12 = /h[12]/.test(token.tag);
21
+ const setextWithAtx =
22
+ (style === "setext_with_atx") &&
23
+ ((h12 && (styleForToken === "setext")) ||
24
+ (!h12 && (styleForToken === "atx")));
25
+ const setextWithAtxClosed =
26
+ (style === "setext_with_atx_closed") &&
27
+ ((h12 && (styleForToken === "setext")) ||
28
+ (!h12 && (styleForToken === "atx_closed")));
29
+ if (!setextWithAtx && !setextWithAtxClosed) {
30
+ let expected = style;
31
+ if (style === "setext_with_atx") {
32
+ expected = h12 ? "setext" : "atx";
33
+ } else if (style === "setext_with_atx_closed") {
34
+ expected = h12 ? "setext" : "atx_closed";
35
+ }
36
+ addErrorDetailIf(onError, token.lineNumber,
37
+ expected, styleForToken);
38
+ }
39
+ }
40
+ });
41
+ }
42
+ };
@@ -0,0 +1,76 @@
1
+ // @ts-check
2
+
3
+ "use strict";
4
+
5
+ const { addErrorDetailIf, listItemMarkerRe, unorderedListStyleFor } =
6
+ require("../helpers");
7
+ const { flattenedLists } = require("./cache");
8
+
9
+ const expectedStyleToMarker = {
10
+ "dash": "-",
11
+ "plus": "+",
12
+ "asterisk": "*"
13
+ };
14
+ const differentItemStyle = {
15
+ "dash": "plus",
16
+ "plus": "asterisk",
17
+ "asterisk": "dash"
18
+ };
19
+ const validStyles = Object.keys(expectedStyleToMarker);
20
+
21
+ module.exports = {
22
+ "names": [ "MD004", "ul-style" ],
23
+ "description": "Unordered list style",
24
+ "tags": [ "bullet", "ul" ],
25
+ "function": function MD004(params, onError) {
26
+ const style = String(params.config.style || "consistent");
27
+ let expectedStyle = style;
28
+ const nestingStyles = [];
29
+ for (const list of flattenedLists()) {
30
+ if (list.unordered) {
31
+ if (expectedStyle === "consistent") {
32
+ expectedStyle = unorderedListStyleFor(list.items[0]);
33
+ }
34
+ for (const item of list.items) {
35
+ const itemStyle = unorderedListStyleFor(item);
36
+ if (style === "sublist") {
37
+ const nesting = list.nesting;
38
+ if (!nestingStyles[nesting]) {
39
+ nestingStyles[nesting] =
40
+ (itemStyle === nestingStyles[nesting - 1]) ?
41
+ differentItemStyle[itemStyle] :
42
+ itemStyle;
43
+ }
44
+ expectedStyle = nestingStyles[nesting];
45
+ }
46
+ if (!validStyles.includes(expectedStyle)) {
47
+ expectedStyle = validStyles[0];
48
+ }
49
+ let range = null;
50
+ let fixInfo = null;
51
+ const match = item.line.match(listItemMarkerRe);
52
+ if (match) {
53
+ const column = match.index + 1;
54
+ const length = match[0].length;
55
+ range = [ column, length ];
56
+ fixInfo = {
57
+ "editColumn": match[1].length + 1,
58
+ "deleteCount": 1,
59
+ "insertText": expectedStyleToMarker[expectedStyle]
60
+ };
61
+ }
62
+ addErrorDetailIf(
63
+ onError,
64
+ item.lineNumber,
65
+ expectedStyle,
66
+ itemStyle,
67
+ null,
68
+ null,
69
+ range,
70
+ fixInfo
71
+ );
72
+ }
73
+ }
74
+ }
75
+ }
76
+ };
@@ -0,0 +1,73 @@
1
+ // @ts-check
2
+
3
+ "use strict";
4
+
5
+ const { addError, addErrorDetailIf } = require("../helpers");
6
+ const { filterByTypes, inHtmlFlow } = require("../helpers/micromark.cjs");
7
+
8
+ module.exports = {
9
+ "names": [ "MD005", "list-indent" ],
10
+ "description": "Inconsistent indentation for list items at the same level",
11
+ "tags": [ "bullet", "ul", "indentation" ],
12
+ "function": function MD005(params, onError) {
13
+ const lists = filterByTypes(
14
+ params.parsers.micromark.tokens,
15
+ [ "listOrdered", "listUnordered" ]
16
+ ).filter((list) => !inHtmlFlow(list));
17
+ for (const list of lists) {
18
+ const expectedIndent = list.startColumn - 1;
19
+ let expectedEnd = 0;
20
+ let endMatching = false;
21
+ const listItemPrefixes =
22
+ list.children.filter((token) => (token.type === "listItemPrefix"));
23
+ for (const listItemPrefix of listItemPrefixes) {
24
+ const lineNumber = listItemPrefix.startLine;
25
+ const actualIndent = listItemPrefix.startColumn - 1;
26
+ const markerLength = listItemPrefix.text.trim().length;
27
+ const range = [ 1, listItemPrefix.startColumn + markerLength ];
28
+ if (list.type === "listUnordered") {
29
+ addErrorDetailIf(
30
+ onError,
31
+ lineNumber,
32
+ expectedIndent,
33
+ actualIndent,
34
+ null,
35
+ null,
36
+ range
37
+ // No fixInfo; MD007 handles this scenario better
38
+ );
39
+ } else {
40
+ const actualEnd = range[1] - 1;
41
+ expectedEnd = expectedEnd || actualEnd;
42
+ if ((expectedIndent !== actualIndent) || endMatching) {
43
+ if (expectedEnd === actualEnd) {
44
+ endMatching = true;
45
+ } else {
46
+ const detail = endMatching ?
47
+ `Expected: (${expectedEnd}); Actual: (${actualEnd})` :
48
+ `Expected: ${expectedIndent}; Actual: ${actualIndent}`;
49
+ const expected = endMatching ?
50
+ expectedEnd - markerLength :
51
+ expectedIndent;
52
+ const actual = endMatching ?
53
+ actualEnd - markerLength :
54
+ actualIndent;
55
+ addError(
56
+ onError,
57
+ lineNumber,
58
+ detail,
59
+ undefined,
60
+ range,
61
+ {
62
+ "editColumn": Math.min(actual, expected) + 1,
63
+ "deleteCount": Math.max(actual - expected, 0),
64
+ "insertText": "".padEnd(Math.max(expected - actual, 0))
65
+ }
66
+ );
67
+ }
68
+ }
69
+ }
70
+ }
71
+ }
72
+ }
73
+ };
@@ -0,0 +1,86 @@
1
+ // @ts-check
2
+
3
+ "use strict";
4
+
5
+ const { addErrorDetailIf } = require("../helpers");
6
+ const { filterByTypes, getTokenParentOfType, inHtmlFlow } =
7
+ require("../helpers/micromark.cjs");
8
+
9
+ /**
10
+ * @typedef {import("../helpers/micromark.cjs").Token} Token
11
+ */
12
+
13
+ const unorderedListTypes =
14
+ [ "blockQuotePrefix", "listItemPrefix", "listUnordered" ];
15
+ const unorderedParentTypes =
16
+ [ "blockQuote", "listOrdered", "listUnordered" ];
17
+
18
+ module.exports = {
19
+ "names": [ "MD007", "ul-indent" ],
20
+ "description": "Unordered list indentation",
21
+ "tags": [ "bullet", "ul", "indentation" ],
22
+ "function": function MD007(params, onError) {
23
+ const indent = Number(params.config.indent || 2);
24
+ const startIndented = !!params.config.start_indented;
25
+ const startIndent = Number(params.config.start_indent || indent);
26
+ const unorderedListNesting = new Map();
27
+ let lastBlockQuotePrefix = null;
28
+ const tokens = filterByTypes(
29
+ params.parsers.micromark.tokens,
30
+ unorderedListTypes
31
+ );
32
+ for (const token of tokens) {
33
+ const { parent, startColumn, startLine, type } = token;
34
+ if (type === "blockQuotePrefix") {
35
+ lastBlockQuotePrefix = token;
36
+ } else if (type === "listUnordered") {
37
+ let nesting = 0;
38
+ /** @type {Token | null} */
39
+ let current = token;
40
+ while (
41
+ (current = getTokenParentOfType(current, unorderedParentTypes))
42
+ ) {
43
+ if (current.type === "listUnordered") {
44
+ nesting++;
45
+ continue;
46
+ } else if (current.type === "listOrdered") {
47
+ nesting = -1;
48
+ }
49
+ break;
50
+ }
51
+ if (nesting >= 0) {
52
+ unorderedListNesting.set(token, nesting);
53
+ }
54
+ } else if (!inHtmlFlow(token)) {
55
+ // listItemPrefix
56
+ const nesting = unorderedListNesting.get(parent);
57
+ if (nesting !== undefined) {
58
+ // listItemPrefix for listUnordered
59
+ const expectedIndent =
60
+ (startIndented ? startIndent : 0) + (nesting * indent);
61
+ const blockQuoteAdjustment =
62
+ (lastBlockQuotePrefix?.endLine === startLine) ?
63
+ (lastBlockQuotePrefix.endColumn - 1) :
64
+ 0;
65
+ const actualIndent = startColumn - 1 - blockQuoteAdjustment;
66
+ const range = [ 1, startColumn + 1 ];
67
+ const fixInfo = {
68
+ "editColumn": startColumn - actualIndent,
69
+ "deleteCount": Math.max(actualIndent - expectedIndent, 0),
70
+ "insertText": "".padEnd(Math.max(expectedIndent - actualIndent, 0))
71
+ };
72
+ addErrorDetailIf(
73
+ onError,
74
+ startLine,
75
+ expectedIndent,
76
+ actualIndent,
77
+ undefined,
78
+ undefined,
79
+ range,
80
+ fixInfo
81
+ );
82
+ }
83
+ }
84
+ }
85
+ }
86
+ };
@@ -0,0 +1,86 @@
1
+ // @ts-check
2
+
3
+ "use strict";
4
+
5
+ const { addError, filterTokens, forEachLine, includesSorted,
6
+ numericSortAscending } = require("../helpers");
7
+ const { lineMetadata } = require("./cache");
8
+
9
+ module.exports = {
10
+ "names": [ "MD009", "no-trailing-spaces" ],
11
+ "description": "Trailing spaces",
12
+ "tags": [ "whitespace" ],
13
+ "function": function MD009(params, onError) {
14
+ let brSpaces = params.config.br_spaces;
15
+ brSpaces = Number((brSpaces === undefined) ? 2 : brSpaces);
16
+ const listItemEmptyLines = !!params.config.list_item_empty_lines;
17
+ const strict = !!params.config.strict;
18
+ const listItemLineNumbers = [];
19
+ if (listItemEmptyLines) {
20
+ filterTokens(params, "list_item_open", (token) => {
21
+ for (let i = token.map[0]; i < token.map[1]; i++) {
22
+ listItemLineNumbers.push(i + 1);
23
+ }
24
+ });
25
+ listItemLineNumbers.sort(numericSortAscending);
26
+ }
27
+ const paragraphLineNumbers = [];
28
+ const codeInlineLineNumbers = [];
29
+ if (strict) {
30
+ filterTokens(params, "paragraph_open", (token) => {
31
+ for (let i = token.map[0]; i < token.map[1] - 1; i++) {
32
+ paragraphLineNumbers.push(i + 1);
33
+ }
34
+ });
35
+ const addLineNumberRange = (start, end) => {
36
+ for (let i = start; i < end; i++) {
37
+ codeInlineLineNumbers.push(i);
38
+ }
39
+ };
40
+ filterTokens(params, "inline", (token) => {
41
+ let start = 0;
42
+ for (const child of token.children) {
43
+ if (start > 0) {
44
+ addLineNumberRange(start, child.lineNumber);
45
+ start = 0;
46
+ }
47
+ if (child.type === "code_inline") {
48
+ start = child.lineNumber;
49
+ }
50
+ }
51
+ if (start > 0) {
52
+ addLineNumberRange(start, token.map[1]);
53
+ }
54
+ });
55
+ }
56
+ const expected = (brSpaces < 2) ? 0 : brSpaces;
57
+ forEachLine(lineMetadata(), (line, lineIndex, inCode) => {
58
+ const lineNumber = lineIndex + 1;
59
+ const trailingSpaces = line.length - line.trimEnd().length;
60
+ if (
61
+ trailingSpaces &&
62
+ !inCode &&
63
+ !includesSorted(listItemLineNumbers, lineNumber) &&
64
+ (
65
+ (expected !== trailingSpaces) ||
66
+ (strict &&
67
+ (!includesSorted(paragraphLineNumbers, lineNumber) ||
68
+ includesSorted(codeInlineLineNumbers, lineNumber)))
69
+ )
70
+ ) {
71
+ const column = line.length - trailingSpaces + 1;
72
+ addError(
73
+ onError,
74
+ lineNumber,
75
+ "Expected: " + (expected === 0 ? "" : "0 or ") +
76
+ expected + "; Actual: " + trailingSpaces,
77
+ undefined,
78
+ [ column, trailingSpaces ],
79
+ {
80
+ "editColumn": column,
81
+ "deleteCount": trailingSpaces
82
+ });
83
+ }
84
+ });
85
+ }
86
+ };
@@ -0,0 +1,60 @@
1
+ // @ts-check
2
+
3
+ "use strict";
4
+
5
+ const { addError, filterTokens, forEachLine, withinAnyRange } =
6
+ require("../helpers");
7
+ const { codeBlockAndSpanRanges, lineMetadata } = require("./cache");
8
+
9
+ const tabRe = /\t+/g;
10
+
11
+ module.exports = {
12
+ "names": [ "MD010", "no-hard-tabs" ],
13
+ "description": "Hard tabs",
14
+ "tags": [ "whitespace", "hard_tab" ],
15
+ "function": function MD010(params, onError) {
16
+ const codeBlocks = params.config.code_blocks;
17
+ const includeCode = (codeBlocks === undefined) ? true : !!codeBlocks;
18
+ const ignoreCodeLanguages = new Set(
19
+ (params.config.ignore_code_languages || [])
20
+ .map((language) => language.toLowerCase())
21
+ );
22
+ const spacesPerTab = params.config.spaces_per_tab;
23
+ const spaceMultiplier = (spacesPerTab === undefined) ?
24
+ 1 :
25
+ Math.max(0, Number(spacesPerTab));
26
+ const exclusions = includeCode ? [] : codeBlockAndSpanRanges();
27
+ filterTokens(params, "fence", (token) => {
28
+ const language = token.info.trim().toLowerCase();
29
+ if (ignoreCodeLanguages.has(language)) {
30
+ for (let i = token.map[0] + 1; i < token.map[1] - 1; i++) {
31
+ exclusions.push([ i, 0, params.lines[i].length ]);
32
+ }
33
+ }
34
+ });
35
+ forEachLine(lineMetadata(), (line, lineIndex, inCode) => {
36
+ if (includeCode || !inCode) {
37
+ let match = null;
38
+ while ((match = tabRe.exec(line)) !== null) {
39
+ const { index } = match;
40
+ const column = index + 1;
41
+ const length = match[0].length;
42
+ if (!withinAnyRange(exclusions, lineIndex, index, length)) {
43
+ addError(
44
+ onError,
45
+ lineIndex + 1,
46
+ "Column: " + column,
47
+ null,
48
+ [ column, length ],
49
+ {
50
+ "editColumn": column,
51
+ "deleteCount": length,
52
+ "insertText": "".padEnd(length * spaceMultiplier)
53
+ }
54
+ );
55
+ }
56
+ }
57
+ }
58
+ });
59
+ }
60
+ };
@@ -0,0 +1,46 @@
1
+ // @ts-check
2
+
3
+ "use strict";
4
+
5
+ const { addError, forEachLine, withinAnyRange } = require("../helpers");
6
+ const { codeBlockAndSpanRanges, lineMetadata } = require("./cache");
7
+
8
+ const reversedLinkRe =
9
+ /(^|[^\\])\(([^()]+)\)\[([^\]^][^\]]*)\](?!\()/g;
10
+
11
+ module.exports = {
12
+ "names": [ "MD011", "no-reversed-links" ],
13
+ "description": "Reversed link syntax",
14
+ "tags": [ "links" ],
15
+ "function": function MD011(params, onError) {
16
+ const exclusions = codeBlockAndSpanRanges();
17
+ forEachLine(lineMetadata(), (line, lineIndex, inCode, onFence) => {
18
+ if (!inCode && !onFence) {
19
+ let match = null;
20
+ while ((match = reversedLinkRe.exec(line)) !== null) {
21
+ const [ reversedLink, preChar, linkText, linkDestination ] = match;
22
+ const index = match.index + preChar.length;
23
+ const length = match[0].length - preChar.length;
24
+ if (
25
+ !linkText.endsWith("\\") &&
26
+ !linkDestination.endsWith("\\") &&
27
+ !withinAnyRange(exclusions, lineIndex, index, length)
28
+ ) {
29
+ addError(
30
+ onError,
31
+ lineIndex + 1,
32
+ reversedLink.slice(preChar.length),
33
+ undefined,
34
+ [ index + 1, length ],
35
+ {
36
+ "editColumn": index + 1,
37
+ "deleteCount": length,
38
+ "insertText": `[${linkText}](${linkDestination})`
39
+ }
40
+ );
41
+ }
42
+ }
43
+ }
44
+ });
45
+ }
46
+ };
@@ -0,0 +1,32 @@
1
+ // @ts-check
2
+
3
+ "use strict";
4
+
5
+ const { addErrorDetailIf, forEachLine } = require("../helpers");
6
+ const { lineMetadata } = require("./cache");
7
+
8
+ module.exports = {
9
+ "names": [ "MD012", "no-multiple-blanks" ],
10
+ "description": "Multiple consecutive blank lines",
11
+ "tags": [ "whitespace", "blank_lines" ],
12
+ "function": function MD012(params, onError) {
13
+ const maximum = Number(params.config.maximum || 1);
14
+ let count = 0;
15
+ forEachLine(lineMetadata(), (line, lineIndex, inCode) => {
16
+ count = (inCode || (line.trim().length > 0)) ? 0 : count + 1;
17
+ if (maximum < count) {
18
+ addErrorDetailIf(
19
+ onError,
20
+ lineIndex + 1,
21
+ maximum,
22
+ count,
23
+ null,
24
+ null,
25
+ null,
26
+ {
27
+ "deleteCount": -1
28
+ });
29
+ }
30
+ });
31
+ }
32
+ };
@@ -0,0 +1,96 @@
1
+ // @ts-check
2
+
3
+ "use strict";
4
+
5
+ const { addErrorDetailIf, filterTokens, forEachHeading, forEachLine,
6
+ includesSorted } = require("../helpers");
7
+ const { lineMetadata, referenceLinkImageData } = require("./cache");
8
+
9
+ const longLineRePrefix = "^.{";
10
+ const longLineRePostfixRelaxed = "}.*\\s.*$";
11
+ const longLineRePostfixStrict = "}.+$";
12
+ const linkOrImageOnlyLineRe = /^[es]*(?:lT?L|I)[ES]*$/;
13
+ const sternModeRe = /^(?:[#>\s]*\s)?\S*$/;
14
+ const tokenTypeMap = {
15
+ "em_open": "e",
16
+ "em_close": "E",
17
+ "image": "I",
18
+ "link_open": "l",
19
+ "link_close": "L",
20
+ "strong_open": "s",
21
+ "strong_close": "S",
22
+ "text": "T"
23
+ };
24
+
25
+ module.exports = {
26
+ "names": [ "MD013", "line-length" ],
27
+ "description": "Line length",
28
+ "tags": [ "line_length" ],
29
+ "function": function MD013(params, onError) {
30
+ const lineLength = Number(params.config.line_length || 80);
31
+ const headingLineLength =
32
+ Number(params.config.heading_line_length || lineLength);
33
+ const codeLineLength =
34
+ Number(params.config.code_block_line_length || lineLength);
35
+ const strict = !!params.config.strict;
36
+ const stern = !!params.config.stern;
37
+ const longLineRePostfix =
38
+ (strict || stern) ? longLineRePostfixStrict : longLineRePostfixRelaxed;
39
+ const longLineRe =
40
+ new RegExp(longLineRePrefix + lineLength + longLineRePostfix);
41
+ const longHeadingLineRe =
42
+ new RegExp(longLineRePrefix + headingLineLength + longLineRePostfix);
43
+ const longCodeLineRe =
44
+ new RegExp(longLineRePrefix + codeLineLength + longLineRePostfix);
45
+ const codeBlocks = params.config.code_blocks;
46
+ const includeCodeBlocks = (codeBlocks === undefined) ? true : !!codeBlocks;
47
+ const tables = params.config.tables;
48
+ const includeTables = (tables === undefined) ? true : !!tables;
49
+ const headings = params.config.headings;
50
+ const includeHeadings = (headings === undefined) ? true : !!headings;
51
+ const headingLineNumbers = [];
52
+ forEachHeading(params, (heading) => {
53
+ headingLineNumbers.push(heading.lineNumber);
54
+ });
55
+ const linkOnlyLineNumbers = [];
56
+ filterTokens(params, "inline", (token) => {
57
+ let childTokenTypes = "";
58
+ for (const child of token.children) {
59
+ if (child.type !== "text" || child.content !== "") {
60
+ childTokenTypes += tokenTypeMap[child.type] || "x";
61
+ }
62
+ }
63
+ if (linkOrImageOnlyLineRe.test(childTokenTypes)) {
64
+ linkOnlyLineNumbers.push(token.lineNumber);
65
+ }
66
+ });
67
+ const { definitionLineIndices } = referenceLinkImageData();
68
+ forEachLine(lineMetadata(), (line, lineIndex, inCode, onFence, inTable) => {
69
+ const lineNumber = lineIndex + 1;
70
+ const isHeading = includesSorted(headingLineNumbers, lineNumber);
71
+ const length = inCode ?
72
+ codeLineLength :
73
+ (isHeading ? headingLineLength : lineLength);
74
+ const lengthRe = inCode ?
75
+ longCodeLineRe :
76
+ (isHeading ? longHeadingLineRe : longLineRe);
77
+ if ((includeCodeBlocks || !inCode) &&
78
+ (includeTables || !inTable) &&
79
+ (includeHeadings || !isHeading) &&
80
+ !includesSorted(definitionLineIndices, lineIndex) &&
81
+ (strict ||
82
+ (!(stern && sternModeRe.test(line)) &&
83
+ !includesSorted(linkOnlyLineNumbers, lineNumber))) &&
84
+ lengthRe.test(line)) {
85
+ addErrorDetailIf(
86
+ onError,
87
+ lineNumber,
88
+ length,
89
+ line.length,
90
+ null,
91
+ null,
92
+ [ length + 1, line.length - length ]);
93
+ }
94
+ });
95
+ }
96
+ };
@@ -0,0 +1,53 @@
1
+ // @ts-check
2
+
3
+ "use strict";
4
+
5
+ const { addErrorContext, filterTokens } = require("../helpers");
6
+
7
+ const dollarCommandRe = /^(\s*)(\$\s+)/;
8
+
9
+ module.exports = {
10
+ "names": [ "MD014", "commands-show-output" ],
11
+ "description": "Dollar signs used before commands without showing output",
12
+ "tags": [ "code" ],
13
+ "function": function MD014(params, onError) {
14
+ for (const type of [ "code_block", "fence" ]) {
15
+ filterTokens(params, type, (token) => {
16
+ const margin = (token.type === "fence") ? 1 : 0;
17
+ const dollarInstances = [];
18
+ let allDollars = true;
19
+ for (let i = token.map[0] + margin; i < token.map[1] - margin; i++) {
20
+ const line = params.lines[i];
21
+ const lineTrim = line.trim();
22
+ if (lineTrim) {
23
+ const match = dollarCommandRe.exec(line);
24
+ if (match) {
25
+ const column = match[1].length + 1;
26
+ const length = match[2].length;
27
+ dollarInstances.push([ i, lineTrim, column, length ]);
28
+ } else {
29
+ allDollars = false;
30
+ }
31
+ }
32
+ }
33
+ if (allDollars) {
34
+ for (const instance of dollarInstances) {
35
+ const [ i, lineTrim, column, length ] = instance;
36
+ addErrorContext(
37
+ onError,
38
+ i + 1,
39
+ lineTrim,
40
+ null,
41
+ null,
42
+ [ column, length ],
43
+ {
44
+ "editColumn": column,
45
+ "deleteCount": length
46
+ }
47
+ );
48
+ }
49
+ }
50
+ });
51
+ }
52
+ }
53
+ };