@alexlit/lint-kit 107.2.2 → 108.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 (256) hide show
  1. package/.eslintrc.cjs +9 -0
  2. package/.linthtmlrc.cjs +5 -0
  3. package/{.commitlintrc.js → commitlint.config.js} +1 -1
  4. package/package.json +11 -10
  5. package/packages/config-commitlint/LICENSE +20 -0
  6. package/packages/config-commitlint/README.md +5 -9
  7. package/packages/config-commitlint/index.js +1 -1
  8. package/packages/config-commitlint/package.json +4 -3
  9. package/packages/config-eslint/LICENSE +20 -0
  10. package/packages/config-eslint/dictionaries/index.js +2 -1
  11. package/packages/config-eslint/index.js +14 -3
  12. package/packages/config-eslint/package.json +25 -25
  13. package/packages/config-eslint/plugins/typescript/index.js +1 -1
  14. package/packages/config-eslint/plugins/unicorn.js +2 -0
  15. package/packages/config-eslint/plugins/vue.js +34 -2
  16. package/packages/config-hooks/LICENSE +20 -0
  17. package/packages/config-hooks/README.md +18 -12
  18. package/packages/config-hooks/index.js +2 -0
  19. package/packages/config-hooks/lint-staged.js +4 -4
  20. package/packages/config-hooks/package.json +6 -5
  21. package/packages/config-htmllint/LICENSE +20 -0
  22. package/packages/config-markdownlint/LICENSE +20 -0
  23. package/packages/config-markdownlint/README.md +5 -5
  24. package/packages/config-markdownlint/index.json +17 -0
  25. package/packages/config-markdownlint/package.json +5 -5
  26. package/packages/config-npmlint/LICENSE +20 -0
  27. package/packages/config-npmlint/package.json +2 -2
  28. package/packages/config-prettier/LICENSE +20 -0
  29. package/packages/config-prettier/README.md +8 -3
  30. package/packages/config-prettier/index.js +14 -10
  31. package/packages/config-prettier/package.json +16 -12
  32. package/packages/config-prettier/plugins/jsdoc.js +1 -1
  33. package/packages/config-prettier/plugins/pug.js +1 -1
  34. package/packages/config-prettier/plugins/sort-json.js +1 -1
  35. package/packages/config-prettier/plugins/svelte.js +1 -1
  36. package/packages/config-prettier/plugins/tailwindcss.js +1 -1
  37. package/packages/config-prettier/plugins/xml.js +1 -1
  38. package/packages/config-stylelint/LICENSE +20 -0
  39. package/packages/config-stylelint/README.md +5 -4
  40. package/packages/config-stylelint/index.js +22 -25
  41. package/packages/config-stylelint/package.json +22 -18
  42. package/packages/config-stylelint/plugins/a11y.js +1 -1
  43. package/packages/config-stylelint/plugins/at-rule-no-children.js +1 -1
  44. package/packages/config-stylelint/plugins/color-format.js +1 -1
  45. package/packages/config-stylelint/plugins/declaration-block-no-ignored-properties.js +1 -1
  46. package/packages/config-stylelint/plugins/high-performance-animation.js +1 -1
  47. package/packages/config-stylelint/plugins/no-nested-media.js +1 -1
  48. package/packages/config-stylelint/plugins/no-unresolved-module.js +1 -1
  49. package/packages/config-stylelint/plugins/no-unsupported-browser-features.js +1 -1
  50. package/packages/config-stylelint/plugins/optional/gamut.js +1 -1
  51. package/packages/config-stylelint/plugins/optional/logical-css.js +1 -1
  52. package/packages/config-stylelint/plugins/optional/no-indistinguishable-colors.js +1 -1
  53. package/packages/config-stylelint/plugins/order.js +1 -1
  54. package/packages/config-stylelint/plugins/prettier.js +1 -1
  55. package/packages/config-stylelint/plugins/scss.js +1 -1
  56. package/packages/config-stylelint/plugins/selector-no-empty.js +1 -1
  57. package/packages/config-stylelint/plugins/use-nesting.js +1 -1
  58. package/packages/config-stylelint/plugins/vue.js +1 -1
  59. package/prettier.config.js +5 -0
  60. package/scripts/lint.eslint.sh +1 -1
  61. package/scripts/lint.markdownlint.sh +1 -1
  62. package/stylelint.config.js +14 -0
  63. package/.eslintrc.js +0 -3
  64. package/.huskyrc.js +0 -3
  65. package/.linthtmlrc.js +0 -3
  66. package/.lintstagedrc.js +0 -3
  67. package/.markdownlintrc.js +0 -3
  68. package/.prettierrc.js +0 -3
  69. package/.stylelintrc.js +0 -4
  70. package/packages/config-hooks/husky.js +0 -6
  71. package/packages/config-markdownlint/index.js +0 -17
  72. package/packages/config-markdownlint/node_modules/markdown-it/LICENSE +0 -22
  73. package/packages/config-markdownlint/node_modules/markdown-it/README.md +0 -309
  74. package/packages/config-markdownlint/node_modules/markdown-it/bin/markdown-it.js +0 -117
  75. package/packages/config-markdownlint/node_modules/markdown-it/dist/markdown-it.js +0 -8441
  76. package/packages/config-markdownlint/node_modules/markdown-it/dist/markdown-it.min.js +0 -3
  77. package/packages/config-markdownlint/node_modules/markdown-it/index.js +0 -4
  78. package/packages/config-markdownlint/node_modules/markdown-it/lib/common/entities.js +0 -6
  79. package/packages/config-markdownlint/node_modules/markdown-it/lib/common/html_blocks.js +0 -70
  80. package/packages/config-markdownlint/node_modules/markdown-it/lib/common/html_re.js +0 -28
  81. package/packages/config-markdownlint/node_modules/markdown-it/lib/common/utils.js +0 -317
  82. package/packages/config-markdownlint/node_modules/markdown-it/lib/helpers/index.js +0 -7
  83. package/packages/config-markdownlint/node_modules/markdown-it/lib/helpers/parse_link_destination.js +0 -80
  84. package/packages/config-markdownlint/node_modules/markdown-it/lib/helpers/parse_link_label.js +0 -48
  85. package/packages/config-markdownlint/node_modules/markdown-it/lib/helpers/parse_link_title.js +0 -55
  86. package/packages/config-markdownlint/node_modules/markdown-it/lib/index.js +0 -582
  87. package/packages/config-markdownlint/node_modules/markdown-it/lib/parser_block.js +0 -131
  88. package/packages/config-markdownlint/node_modules/markdown-it/lib/parser_core.js +0 -61
  89. package/packages/config-markdownlint/node_modules/markdown-it/lib/parser_inline.js +0 -192
  90. package/packages/config-markdownlint/node_modules/markdown-it/lib/presets/commonmark.js +0 -81
  91. package/packages/config-markdownlint/node_modules/markdown-it/lib/presets/default.js +0 -41
  92. package/packages/config-markdownlint/node_modules/markdown-it/lib/presets/zero.js +0 -63
  93. package/packages/config-markdownlint/node_modules/markdown-it/lib/renderer.js +0 -341
  94. package/packages/config-markdownlint/node_modules/markdown-it/lib/ruler.js +0 -352
  95. package/packages/config-markdownlint/node_modules/markdown-it/lib/rules_block/blockquote.js +0 -226
  96. package/packages/config-markdownlint/node_modules/markdown-it/lib/rules_block/code.js +0 -34
  97. package/packages/config-markdownlint/node_modules/markdown-it/lib/rules_block/fence.js +0 -98
  98. package/packages/config-markdownlint/node_modules/markdown-it/lib/rules_block/heading.js +0 -55
  99. package/packages/config-markdownlint/node_modules/markdown-it/lib/rules_block/hr.js +0 -45
  100. package/packages/config-markdownlint/node_modules/markdown-it/lib/rules_block/html_block.js +0 -74
  101. package/packages/config-markdownlint/node_modules/markdown-it/lib/rules_block/lheading.js +0 -83
  102. package/packages/config-markdownlint/node_modules/markdown-it/lib/rules_block/list.js +0 -362
  103. package/packages/config-markdownlint/node_modules/markdown-it/lib/rules_block/paragraph.js +0 -51
  104. package/packages/config-markdownlint/node_modules/markdown-it/lib/rules_block/reference.js +0 -198
  105. package/packages/config-markdownlint/node_modules/markdown-it/lib/rules_block/state_block.js +0 -231
  106. package/packages/config-markdownlint/node_modules/markdown-it/lib/rules_block/table.js +0 -221
  107. package/packages/config-markdownlint/node_modules/markdown-it/lib/rules_core/block.js +0 -16
  108. package/packages/config-markdownlint/node_modules/markdown-it/lib/rules_core/inline.js +0 -13
  109. package/packages/config-markdownlint/node_modules/markdown-it/lib/rules_core/linkify.js +0 -142
  110. package/packages/config-markdownlint/node_modules/markdown-it/lib/rules_core/normalize.js +0 -21
  111. package/packages/config-markdownlint/node_modules/markdown-it/lib/rules_core/replacements.js +0 -105
  112. package/packages/config-markdownlint/node_modules/markdown-it/lib/rules_core/smartquotes.js +0 -201
  113. package/packages/config-markdownlint/node_modules/markdown-it/lib/rules_core/state_core.js +0 -20
  114. package/packages/config-markdownlint/node_modules/markdown-it/lib/rules_core/text_join.js +0 -45
  115. package/packages/config-markdownlint/node_modules/markdown-it/lib/rules_inline/autolink.js +0 -76
  116. package/packages/config-markdownlint/node_modules/markdown-it/lib/rules_inline/backticks.js +0 -63
  117. package/packages/config-markdownlint/node_modules/markdown-it/lib/rules_inline/balance_pairs.js +0 -130
  118. package/packages/config-markdownlint/node_modules/markdown-it/lib/rules_inline/emphasis.js +0 -130
  119. package/packages/config-markdownlint/node_modules/markdown-it/lib/rules_inline/entity.js +0 -55
  120. package/packages/config-markdownlint/node_modules/markdown-it/lib/rules_inline/escape.js +0 -71
  121. package/packages/config-markdownlint/node_modules/markdown-it/lib/rules_inline/fragments_join.js +0 -41
  122. package/packages/config-markdownlint/node_modules/markdown-it/lib/rules_inline/html_inline.js +0 -58
  123. package/packages/config-markdownlint/node_modules/markdown-it/lib/rules_inline/image.js +0 -152
  124. package/packages/config-markdownlint/node_modules/markdown-it/lib/rules_inline/link.js +0 -150
  125. package/packages/config-markdownlint/node_modules/markdown-it/lib/rules_inline/linkify.js +0 -62
  126. package/packages/config-markdownlint/node_modules/markdown-it/lib/rules_inline/newline.js +0 -46
  127. package/packages/config-markdownlint/node_modules/markdown-it/lib/rules_inline/state_inline.js +0 -158
  128. package/packages/config-markdownlint/node_modules/markdown-it/lib/rules_inline/strikethrough.js +0 -130
  129. package/packages/config-markdownlint/node_modules/markdown-it/lib/rules_inline/text.js +0 -89
  130. package/packages/config-markdownlint/node_modules/markdown-it/lib/token.js +0 -201
  131. package/packages/config-markdownlint/node_modules/markdown-it/package.json +0 -87
  132. package/packages/config-markdownlint/node_modules/markdownlint/CHANGELOG.md +0 -428
  133. package/packages/config-markdownlint/node_modules/markdownlint/CONTRIBUTING.md +0 -92
  134. package/packages/config-markdownlint/node_modules/markdownlint/LICENSE +0 -21
  135. package/packages/config-markdownlint/node_modules/markdownlint/README.md +0 -1026
  136. package/packages/config-markdownlint/node_modules/markdownlint/demo/markdownlint-browser.js +0 -6814
  137. package/packages/config-markdownlint/node_modules/markdownlint/doc/CustomRules.md +0 -376
  138. package/packages/config-markdownlint/node_modules/markdownlint/doc/Prettier.md +0 -27
  139. package/packages/config-markdownlint/node_modules/markdownlint/doc/ReleaseProcess.md +0 -20
  140. package/packages/config-markdownlint/node_modules/markdownlint/doc/Rules.md +0 -2335
  141. package/packages/config-markdownlint/node_modules/markdownlint/doc/md001.md +0 -37
  142. package/packages/config-markdownlint/node_modules/markdownlint/doc/md003.md +0 -59
  143. package/packages/config-markdownlint/node_modules/markdownlint/doc/md004.md +0 -49
  144. package/packages/config-markdownlint/node_modules/markdownlint/doc/md005.md +0 -53
  145. package/packages/config-markdownlint/node_modules/markdownlint/doc/md007.md +0 -52
  146. package/packages/config-markdownlint/node_modules/markdownlint/doc/md009.md +0 -51
  147. package/packages/config-markdownlint/node_modules/markdownlint/doc/md010.md +0 -56
  148. package/packages/config-markdownlint/node_modules/markdownlint/doc/md011.md +0 -30
  149. package/packages/config-markdownlint/node_modules/markdownlint/doc/md012.md +0 -38
  150. package/packages/config-markdownlint/node_modules/markdownlint/doc/md013.md +0 -57
  151. package/packages/config-markdownlint/node_modules/markdownlint/doc/md014.md +0 -54
  152. package/packages/config-markdownlint/node_modules/markdownlint/doc/md018.md +0 -27
  153. package/packages/config-markdownlint/node_modules/markdownlint/doc/md019.md +0 -28
  154. package/packages/config-markdownlint/node_modules/markdownlint/doc/md020.md +0 -29
  155. package/packages/config-markdownlint/node_modules/markdownlint/doc/md021.md +0 -31
  156. package/packages/config-markdownlint/node_modules/markdownlint/doc/md022.md +0 -52
  157. package/packages/config-markdownlint/node_modules/markdownlint/doc/md023.md +0 -33
  158. package/packages/config-markdownlint/node_modules/markdownlint/doc/md024.md +0 -47
  159. package/packages/config-markdownlint/node_modules/markdownlint/doc/md025.md +0 -49
  160. package/packages/config-markdownlint/node_modules/markdownlint/doc/md026.md +0 -40
  161. package/packages/config-markdownlint/node_modules/markdownlint/doc/md027.md +0 -24
  162. package/packages/config-markdownlint/node_modules/markdownlint/doc/md028.md +0 -40
  163. package/packages/config-markdownlint/node_modules/markdownlint/doc/md029.md +0 -98
  164. package/packages/config-markdownlint/node_modules/markdownlint/doc/md030.md +0 -82
  165. package/packages/config-markdownlint/node_modules/markdownlint/doc/md031.md +0 -50
  166. package/packages/config-markdownlint/node_modules/markdownlint/doc/md032.md +0 -55
  167. package/packages/config-markdownlint/node_modules/markdownlint/doc/md033.md +0 -27
  168. package/packages/config-markdownlint/node_modules/markdownlint/doc/md034.md +0 -50
  169. package/packages/config-markdownlint/node_modules/markdownlint/doc/md035.md +0 -42
  170. package/packages/config-markdownlint/node_modules/markdownlint/doc/md036.md +0 -45
  171. package/packages/config-markdownlint/node_modules/markdownlint/doc/md037.md +0 -37
  172. package/packages/config-markdownlint/node_modules/markdownlint/doc/md038.md +0 -40
  173. package/packages/config-markdownlint/node_modules/markdownlint/doc/md039.md +0 -21
  174. package/packages/config-markdownlint/node_modules/markdownlint/doc/md040.md +0 -52
  175. package/packages/config-markdownlint/node_modules/markdownlint/doc/md041.md +0 -49
  176. package/packages/config-markdownlint/node_modules/markdownlint/doc/md042.md +0 -32
  177. package/packages/config-markdownlint/node_modules/markdownlint/doc/md043.md +0 -69
  178. package/packages/config-markdownlint/node_modules/markdownlint/doc/md044.md +0 -35
  179. package/packages/config-markdownlint/node_modules/markdownlint/doc/md045.md +0 -40
  180. package/packages/config-markdownlint/node_modules/markdownlint/doc/md046.md +0 -40
  181. package/packages/config-markdownlint/node_modules/markdownlint/doc/md047.md +0 -34
  182. package/packages/config-markdownlint/node_modules/markdownlint/doc/md048.md +0 -41
  183. package/packages/config-markdownlint/node_modules/markdownlint/doc/md049.md +0 -32
  184. package/packages/config-markdownlint/node_modules/markdownlint/doc/md050.md +0 -32
  185. package/packages/config-markdownlint/node_modules/markdownlint/doc/md051.md +0 -61
  186. package/packages/config-markdownlint/node_modules/markdownlint/doc/md052.md +0 -40
  187. package/packages/config-markdownlint/node_modules/markdownlint/doc/md053.md +0 -38
  188. package/packages/config-markdownlint/node_modules/markdownlint/doc/md054.md +0 -100
  189. package/packages/config-markdownlint/node_modules/markdownlint/helpers/LICENSE +0 -21
  190. package/packages/config-markdownlint/node_modules/markdownlint/helpers/README.md +0 -70
  191. package/packages/config-markdownlint/node_modules/markdownlint/helpers/helpers.js +0 -1025
  192. package/packages/config-markdownlint/node_modules/markdownlint/helpers/micromark.cjs +0 -426
  193. package/packages/config-markdownlint/node_modules/markdownlint/helpers/package.json +0 -26
  194. package/packages/config-markdownlint/node_modules/markdownlint/helpers/shared.js +0 -10
  195. package/packages/config-markdownlint/node_modules/markdownlint/lib/cache.js +0 -21
  196. package/packages/config-markdownlint/node_modules/markdownlint/lib/configuration.d.ts +0 -1152
  197. package/packages/config-markdownlint/node_modules/markdownlint/lib/constants.js +0 -14
  198. package/packages/config-markdownlint/node_modules/markdownlint/lib/markdownlint.d.ts +0 -406
  199. package/packages/config-markdownlint/node_modules/markdownlint/lib/markdownlint.js +0 -1476
  200. package/packages/config-markdownlint/node_modules/markdownlint/lib/md001.js +0 -22
  201. package/packages/config-markdownlint/node_modules/markdownlint/lib/md003.js +0 -42
  202. package/packages/config-markdownlint/node_modules/markdownlint/lib/md004.js +0 -76
  203. package/packages/config-markdownlint/node_modules/markdownlint/lib/md005.js +0 -73
  204. package/packages/config-markdownlint/node_modules/markdownlint/lib/md007.js +0 -86
  205. package/packages/config-markdownlint/node_modules/markdownlint/lib/md009.js +0 -86
  206. package/packages/config-markdownlint/node_modules/markdownlint/lib/md010.js +0 -60
  207. package/packages/config-markdownlint/node_modules/markdownlint/lib/md011.js +0 -46
  208. package/packages/config-markdownlint/node_modules/markdownlint/lib/md012.js +0 -32
  209. package/packages/config-markdownlint/node_modules/markdownlint/lib/md013.js +0 -96
  210. package/packages/config-markdownlint/node_modules/markdownlint/lib/md014.js +0 -53
  211. package/packages/config-markdownlint/node_modules/markdownlint/lib/md018.js +0 -34
  212. package/packages/config-markdownlint/node_modules/markdownlint/lib/md019.js +0 -39
  213. package/packages/config-markdownlint/node_modules/markdownlint/lib/md020.js +0 -62
  214. package/packages/config-markdownlint/node_modules/markdownlint/lib/md021.js +0 -62
  215. package/packages/config-markdownlint/node_modules/markdownlint/lib/md022.js +0 -108
  216. package/packages/config-markdownlint/node_modules/markdownlint/lib/md023.js +0 -38
  217. package/packages/config-markdownlint/node_modules/markdownlint/lib/md024.js +0 -38
  218. package/packages/config-markdownlint/node_modules/markdownlint/lib/md025.js +0 -32
  219. package/packages/config-markdownlint/node_modules/markdownlint/lib/md026.js +0 -50
  220. package/packages/config-markdownlint/node_modules/markdownlint/lib/md027.js +0 -56
  221. package/packages/config-markdownlint/node_modules/markdownlint/lib/md028.js +0 -30
  222. package/packages/config-markdownlint/node_modules/markdownlint/lib/md029.js +0 -67
  223. package/packages/config-markdownlint/node_modules/markdownlint/lib/md030.js +0 -61
  224. package/packages/config-markdownlint/node_modules/markdownlint/lib/md031.js +0 -40
  225. package/packages/config-markdownlint/node_modules/markdownlint/lib/md032.js +0 -78
  226. package/packages/config-markdownlint/node_modules/markdownlint/lib/md033.js +0 -39
  227. package/packages/config-markdownlint/node_modules/markdownlint/lib/md034.js +0 -79
  228. package/packages/config-markdownlint/node_modules/markdownlint/lib/md035.js +0 -24
  229. package/packages/config-markdownlint/node_modules/markdownlint/lib/md036.js +0 -56
  230. package/packages/config-markdownlint/node_modules/markdownlint/lib/md037.js +0 -91
  231. package/packages/config-markdownlint/node_modules/markdownlint/lib/md038.js +0 -97
  232. package/packages/config-markdownlint/node_modules/markdownlint/lib/md039.js +0 -67
  233. package/packages/config-markdownlint/node_modules/markdownlint/lib/md040.js +0 -37
  234. package/packages/config-markdownlint/node_modules/markdownlint/lib/md041.js +0 -42
  235. package/packages/config-markdownlint/node_modules/markdownlint/lib/md042.js +0 -49
  236. package/packages/config-markdownlint/node_modules/markdownlint/lib/md043.js +0 -64
  237. package/packages/config-markdownlint/node_modules/markdownlint/lib/md044.js +0 -107
  238. package/packages/config-markdownlint/node_modules/markdownlint/lib/md045.js +0 -60
  239. package/packages/config-markdownlint/node_modules/markdownlint/lib/md046.js +0 -33
  240. package/packages/config-markdownlint/node_modules/markdownlint/lib/md047.js +0 -28
  241. package/packages/config-markdownlint/node_modules/markdownlint/lib/md048.js +0 -30
  242. package/packages/config-markdownlint/node_modules/markdownlint/lib/md049-md050.js +0 -89
  243. package/packages/config-markdownlint/node_modules/markdownlint/lib/md051.js +0 -172
  244. package/packages/config-markdownlint/node_modules/markdownlint/lib/md052.js +0 -39
  245. package/packages/config-markdownlint/node_modules/markdownlint/lib/md053.js +0 -59
  246. package/packages/config-markdownlint/node_modules/markdownlint/lib/md054.js +0 -125
  247. package/packages/config-markdownlint/node_modules/markdownlint/lib/rules.js +0 -65
  248. package/packages/config-markdownlint/node_modules/markdownlint/package.json +0 -109
  249. package/packages/config-markdownlint/node_modules/markdownlint/schema/.markdownlint.jsonc +0 -297
  250. package/packages/config-markdownlint/node_modules/markdownlint/schema/.markdownlint.yaml +0 -266
  251. package/packages/config-markdownlint/node_modules/markdownlint/schema/markdownlint-config-schema.json +0 -1762
  252. package/packages/config-markdownlint/node_modules/markdownlint/style/all.json +0 -5
  253. package/packages/config-markdownlint/node_modules/markdownlint/style/cirosantilli.json +0 -22
  254. package/packages/config-markdownlint/node_modules/markdownlint/style/prettier.json +0 -26
  255. package/packages/config-markdownlint/node_modules/markdownlint/style/relaxed.json +0 -12
  256. /package/packages/config-eslint/plugins/{security.js → optional/security.js} +0 -0
@@ -1,49 +0,0 @@
1
- // @ts-check
2
-
3
- "use strict";
4
-
5
- const { addErrorContext, escapeForRegExp, filterTokens } =
6
- require("../helpers");
7
-
8
- module.exports = {
9
- "names": [ "MD042", "no-empty-links" ],
10
- "description": "No empty links",
11
- "tags": [ "links" ],
12
- "function": function MD042(params, onError) {
13
- filterTokens(params, "inline", function forToken(token) {
14
- let inLink = false;
15
- let linkText = "";
16
- let emptyLink = false;
17
- for (const child of token.children) {
18
- if (child.type === "link_open") {
19
- inLink = true;
20
- linkText = "";
21
- for (const attr of child.attrs) {
22
- if (attr[0] === "href" && (!attr[1] || (attr[1] === "#"))) {
23
- emptyLink = true;
24
- }
25
- }
26
- } else if (child.type === "link_close") {
27
- inLink = false;
28
- if (emptyLink) {
29
- let context = `[${linkText}]`;
30
- let range = null;
31
- const match = child.line.match(
32
- new RegExp(`${escapeForRegExp(context)}\\((?:|#|<>)\\)`)
33
- );
34
- if (match) {
35
- context = match[0];
36
- range = [ match.index + 1, match[0].length ];
37
- }
38
- addErrorContext(
39
- onError, child.lineNumber, context, null, null, range
40
- );
41
- emptyLink = false;
42
- }
43
- } else if (inLink) {
44
- linkText += child.content;
45
- }
46
- }
47
- });
48
- }
49
- };
@@ -1,64 +0,0 @@
1
- // @ts-check
2
-
3
- "use strict";
4
-
5
- const { addErrorContext, addErrorDetailIf, forEachHeading } =
6
- require("../helpers");
7
-
8
- module.exports = {
9
- "names": [ "MD043", "required-headings" ],
10
- "description": "Required heading structure",
11
- "tags": [ "headings" ],
12
- "function": function MD043(params, onError) {
13
- const requiredHeadings = params.config.headings;
14
- if (!Array.isArray(requiredHeadings)) {
15
- // Nothing to check; avoid doing any work
16
- return;
17
- }
18
- const matchCase = params.config.match_case || false;
19
- const levels = {};
20
- for (const level of [ 1, 2, 3, 4, 5, 6 ]) {
21
- levels["h" + level] = "######".substr(-level);
22
- }
23
- let i = 0;
24
- let matchAny = false;
25
- let hasError = false;
26
- let anyHeadings = false;
27
- const getExpected = () => requiredHeadings[i++] || "[None]";
28
- const handleCase = (str) => (matchCase ? str : str.toLowerCase());
29
- forEachHeading(params, (heading, content) => {
30
- if (!hasError) {
31
- anyHeadings = true;
32
- const actual = levels[heading.tag] + " " + content;
33
- const expected = getExpected();
34
- if (expected === "*") {
35
- const nextExpected = getExpected();
36
- if (handleCase(nextExpected) !== handleCase(actual)) {
37
- matchAny = true;
38
- i--;
39
- }
40
- } else if (expected === "+") {
41
- matchAny = true;
42
- } else if (handleCase(expected) === handleCase(actual)) {
43
- matchAny = false;
44
- } else if (matchAny) {
45
- i--;
46
- } else {
47
- addErrorDetailIf(onError, heading.lineNumber,
48
- expected, actual);
49
- hasError = true;
50
- }
51
- }
52
- });
53
- const extraHeadings = requiredHeadings.length - i;
54
- if (
55
- !hasError &&
56
- ((extraHeadings > 1) ||
57
- ((extraHeadings === 1) && (requiredHeadings[i] !== "*"))) &&
58
- (anyHeadings || !requiredHeadings.every((heading) => heading === "*"))
59
- ) {
60
- addErrorContext(onError, params.lines.length,
61
- requiredHeadings[i]);
62
- }
63
- }
64
- };
@@ -1,107 +0,0 @@
1
- // @ts-check
2
-
3
- "use strict";
4
-
5
- const { addErrorDetailIf, escapeForRegExp, withinAnyRange } =
6
- require("../helpers");
7
- const { filterByPredicate, filterByTypes, parse } =
8
- require("../helpers/micromark.cjs");
9
-
10
- const ignoredChildTypes = new Set(
11
- [ "codeFencedFence", "definition", "reference", "resource" ]
12
- );
13
-
14
- module.exports = {
15
- "names": [ "MD044", "proper-names" ],
16
- "description": "Proper names should have the correct capitalization",
17
- "tags": [ "spelling" ],
18
- "function": function MD044(params, onError) {
19
- let names = params.config.names;
20
- names = Array.isArray(names) ? names : [];
21
- names.sort((a, b) => (b.length - a.length) || a.localeCompare(b));
22
- if (names.length === 0) {
23
- // Nothing to check; avoid doing any work
24
- return;
25
- }
26
- const codeBlocks = params.config.code_blocks;
27
- const includeCodeBlocks =
28
- (codeBlocks === undefined) ? true : !!codeBlocks;
29
- const htmlElements = params.config.html_elements;
30
- const includeHtmlElements =
31
- (htmlElements === undefined) ? true : !!htmlElements;
32
- const scannedTypes = new Set([ "data" ]);
33
- if (includeCodeBlocks) {
34
- scannedTypes.add("codeFlowValue");
35
- scannedTypes.add("codeTextData");
36
- }
37
- if (includeHtmlElements) {
38
- scannedTypes.add("htmlFlowData");
39
- scannedTypes.add("htmlTextData");
40
- }
41
- const contentTokens =
42
- filterByPredicate(
43
- params.parsers.micromark.tokens,
44
- (token) => scannedTypes.has(token.type),
45
- (token) => (
46
- token.children.filter((t) => !ignoredChildTypes.has(t.type))
47
- )
48
- );
49
- const exclusions = [];
50
- const autoLinked = new Set();
51
- for (const name of names) {
52
- const escapedName = escapeForRegExp(name);
53
- const startNamePattern = /^\W/.test(name) ? "" : "\\b_*";
54
- const endNamePattern = /\W$/.test(name) ? "" : "_*\\b";
55
- const namePattern =
56
- `(${startNamePattern})(${escapedName})${endNamePattern}`;
57
- const nameRe = new RegExp(namePattern, "gi");
58
- for (const token of contentTokens) {
59
- let match = null;
60
- while ((match = nameRe.exec(token.text)) !== null) {
61
- const [ , leftMatch, nameMatch ] = match;
62
- const index = token.startColumn - 1 + match.index + leftMatch.length;
63
- const length = nameMatch.length;
64
- const lineIndex = token.startLine - 1;
65
- if (
66
- !withinAnyRange(exclusions, lineIndex, index, length) &&
67
- !names.includes(nameMatch)
68
- ) {
69
- let urlRanges = [];
70
- if (!autoLinked.has(token)) {
71
- urlRanges = filterByTypes(
72
- parse(token.text),
73
- [ "literalAutolink" ]
74
- ).map(
75
- (t) => [
76
- lineIndex,
77
- token.startColumn - 1 + t.startColumn - 1,
78
- t.endColumn - t.startColumn
79
- ]
80
- );
81
- exclusions.push(...urlRanges);
82
- autoLinked.add(token);
83
- }
84
- if (!withinAnyRange(urlRanges, lineIndex, index, length)) {
85
- const column = index + 1;
86
- addErrorDetailIf(
87
- onError,
88
- token.startLine,
89
- name,
90
- nameMatch,
91
- null,
92
- null,
93
- [ column, length ],
94
- {
95
- "editColumn": column,
96
- "deleteCount": length,
97
- "insertText": name
98
- }
99
- );
100
- }
101
- }
102
- exclusions.push([ lineIndex, index, length ]);
103
- }
104
- }
105
- }
106
- }
107
- };
@@ -1,60 +0,0 @@
1
- // @ts-check
2
-
3
- "use strict";
4
-
5
- const { addError, getHtmlAttributeRe, nextLinesRe } = require("../helpers");
6
- const { filterByTypes, getHtmlTagInfo } = require("../helpers/micromark.cjs");
7
-
8
- const altRe = getHtmlAttributeRe("alt");
9
-
10
- module.exports = {
11
- "names": [ "MD045", "no-alt-text" ],
12
- "description": "Images should have alternate text (alt text)",
13
- "tags": [ "accessibility", "images" ],
14
- "function": function MD045(params, onError) {
15
- const { tokens } = params.parsers.micromark;
16
-
17
- // Process Markdown images
18
- const images = filterByTypes(tokens, [ "image" ]);
19
- for (const image of images) {
20
- const labelTexts = filterByTypes(image.children, [ "labelText" ]);
21
- if (labelTexts.some((labelText) => labelText.text.length === 0)) {
22
- const range = (image.startLine === image.endLine) ?
23
- [ image.startColumn, image.endColumn - image.startColumn ] :
24
- undefined;
25
- addError(
26
- onError,
27
- image.startLine,
28
- undefined,
29
- undefined,
30
- range
31
- );
32
- }
33
- }
34
-
35
- // Process HTML images
36
- const htmlTexts = filterByTypes(tokens, [ "htmlText" ]);
37
- for (const htmlText of htmlTexts) {
38
- const { startColumn, startLine, text } = htmlText;
39
- const htmlTagInfo = getHtmlTagInfo(htmlText);
40
- if (
41
- htmlTagInfo &&
42
- !htmlTagInfo.close &&
43
- (htmlTagInfo.name.toLowerCase() === "img") &&
44
- !altRe.test(text)
45
- ) {
46
- const range = [
47
- startColumn,
48
- text.replace(nextLinesRe, "").length
49
- ];
50
- addError(
51
- onError,
52
- startLine,
53
- undefined,
54
- undefined,
55
- range
56
- );
57
- }
58
- }
59
- }
60
- };
@@ -1,33 +0,0 @@
1
- // @ts-check
2
-
3
- "use strict";
4
-
5
- const { addErrorDetailIf } = require("../helpers");
6
-
7
- const tokenTypeToStyle = {
8
- "fence": "fenced",
9
- "code_block": "indented"
10
- };
11
-
12
- module.exports = {
13
- "names": [ "MD046", "code-block-style" ],
14
- "description": "Code block style",
15
- "tags": [ "code" ],
16
- "function": function MD046(params, onError) {
17
- let expectedStyle = String(params.config.style || "consistent");
18
- const codeBlocksAndFences = params.parsers.markdownit.tokens.filter(
19
- (token) => (token.type === "code_block") || (token.type === "fence")
20
- );
21
- for (const token of codeBlocksAndFences) {
22
- const { lineNumber, type } = token;
23
- if (expectedStyle === "consistent") {
24
- expectedStyle = tokenTypeToStyle[type];
25
- }
26
- addErrorDetailIf(
27
- onError,
28
- lineNumber,
29
- expectedStyle,
30
- tokenTypeToStyle[type]);
31
- }
32
- }
33
- };
@@ -1,28 +0,0 @@
1
- // @ts-check
2
-
3
- "use strict";
4
-
5
- const { addError, isBlankLine } = require("../helpers");
6
-
7
- module.exports = {
8
- "names": [ "MD047", "single-trailing-newline" ],
9
- "description": "Files should end with a single newline character",
10
- "tags": [ "blank_lines" ],
11
- "function": function MD047(params, onError) {
12
- const lastLineNumber = params.lines.length;
13
- const lastLine = params.lines[lastLineNumber - 1];
14
- if (!isBlankLine(lastLine)) {
15
- addError(
16
- onError,
17
- lastLineNumber,
18
- null,
19
- null,
20
- [ lastLine.length, 1 ],
21
- {
22
- "insertText": "\n",
23
- "editColumn": lastLine.length + 1
24
- }
25
- );
26
- }
27
- }
28
- };
@@ -1,30 +0,0 @@
1
- // @ts-check
2
-
3
- "use strict";
4
-
5
- const { addErrorDetailIf, fencedCodeBlockStyleFor } = require("../helpers");
6
-
7
- module.exports = {
8
- "names": [ "MD048", "code-fence-style" ],
9
- "description": "Code fence style",
10
- "tags": [ "code" ],
11
- "function": function MD048(params, onError) {
12
- const style = String(params.config.style || "consistent");
13
- let expectedStyle = style;
14
- const fenceTokens = params.parsers.markdownit.tokens.filter(
15
- (token) => token.type === "fence"
16
- );
17
- for (const fenceToken of fenceTokens) {
18
- const { lineNumber, markup } = fenceToken;
19
- if (expectedStyle === "consistent") {
20
- expectedStyle = fencedCodeBlockStyleFor(markup);
21
- }
22
- addErrorDetailIf(
23
- onError,
24
- lineNumber,
25
- expectedStyle,
26
- fencedCodeBlockStyleFor(markup)
27
- );
28
- }
29
- }
30
- };
@@ -1,89 +0,0 @@
1
- // @ts-check
2
-
3
- "use strict";
4
-
5
- const { addError, emphasisOrStrongStyleFor } = require("../helpers");
6
- const { filterByPredicate, tokenIfType } = require("../helpers/micromark.cjs");
7
-
8
- const intrawordRe = /\w/;
9
-
10
- const impl =
11
- (params, onError, type, asterisk, underline, style = "consistent") => {
12
- const { lines, parsers } = params;
13
- const emphasisTokens = filterByPredicate(
14
- parsers.micromark.tokens,
15
- (token) => token.type === type,
16
- (token) => ((token.type === "htmlFlow") ? [] : token.children)
17
- );
18
- for (const token of emphasisTokens) {
19
- const { children } = token;
20
- const childType = `${type}Sequence`;
21
- const startSequence = tokenIfType(children[0], childType);
22
- const endSequence = tokenIfType(children[children.length - 1], childType);
23
- if (startSequence && endSequence) {
24
- const markupStyle = emphasisOrStrongStyleFor(startSequence.text);
25
- if (style === "consistent") {
26
- style = markupStyle;
27
- }
28
- if (style !== markupStyle) {
29
- const underscoreIntraword = (style === "underscore") && (
30
- intrawordRe.test(
31
- lines[startSequence.startLine - 1][startSequence.startColumn - 2]
32
- ) ||
33
- intrawordRe.test(
34
- lines[endSequence.endLine - 1][endSequence.endColumn - 1]
35
- )
36
- );
37
- if (!underscoreIntraword) {
38
- for (const sequence of [ startSequence, endSequence ]) {
39
- addError(
40
- onError,
41
- sequence.startLine,
42
- `Expected: ${style}; Actual: ${markupStyle}`,
43
- undefined,
44
- [ sequence.startColumn, sequence.text.length ],
45
- {
46
- "editColumn": sequence.startColumn,
47
- "deleteCount": sequence.text.length,
48
- "insertText": (style === "asterisk") ? asterisk : underline
49
- }
50
- );
51
- }
52
- }
53
- }
54
- }
55
- }
56
- };
57
-
58
- module.exports = [
59
- {
60
- "names": [ "MD049", "emphasis-style" ],
61
- "description": "Emphasis style",
62
- "tags": [ "emphasis" ],
63
- "function": function MD049(params, onError) {
64
- return impl(
65
- params,
66
- onError,
67
- "emphasis",
68
- "*",
69
- "_",
70
- params.config.style || undefined
71
- );
72
- }
73
- },
74
- {
75
- "names": [ "MD050", "strong-style" ],
76
- "description": "Strong style",
77
- "tags": [ "emphasis" ],
78
- "function": function MD050(params, onError) {
79
- return impl(
80
- params,
81
- onError,
82
- "strong",
83
- "**",
84
- "__",
85
- params.config.style || undefined
86
- );
87
- }
88
- }
89
- ];
@@ -1,172 +0,0 @@
1
- // @ts-check
2
-
3
- "use strict";
4
-
5
- const { addError, addErrorDetailIf, getHtmlAttributeRe } =
6
- require("../helpers");
7
- const { filterByPredicate, filterByTypes, getHtmlTagInfo } =
8
- require("../helpers/micromark.cjs");
9
-
10
- // Regular expression for identifying HTML anchor names
11
- const idRe = getHtmlAttributeRe("id");
12
- const nameRe = getHtmlAttributeRe("name");
13
- const anchorRe = /\{(#[a-z\d]+(?:[-_][a-z\d]+)*)\}/gu;
14
-
15
- // Sets for filtering heading tokens during conversion
16
- const childrenExclude = new Set([ "image", "reference", "resource" ]);
17
- const tokensInclude = new Set(
18
- [ "characterEscapeValue", "codeTextData", "data" ]
19
- );
20
-
21
- /**
22
- * @typedef {import("../helpers/micromark.cjs").Token} Token
23
- */
24
-
25
- /**
26
- * Converts a Markdown heading into an HTML fragment according to the rules
27
- * used by GitHub.
28
- *
29
- * @param {Token} headingText Heading text token.
30
- * @returns {string} Fragment string for heading.
31
- */
32
- function convertHeadingToHTMLFragment(headingText) {
33
- const inlineText =
34
- filterByPredicate(
35
- headingText.children,
36
- (token) => tokensInclude.has(token.type),
37
- (token) => (childrenExclude.has(token.type) ? [] : token.children)
38
- )
39
- .map((token) => token.text)
40
- .join("");
41
- return "#" + encodeURIComponent(
42
- inlineText
43
- .toLowerCase()
44
- // RegExp source with Ruby's \p{Word} expanded into its General Categories
45
- // https://github.com/gjtorikian/html-pipeline/blob/main/lib/html/pipeline/toc_filter.rb
46
- // https://ruby-doc.org/core-3.0.2/Regexp.html
47
- .replace(
48
- /[^\p{Letter}\p{Mark}\p{Number}\p{Connector_Punctuation}\- ]/gu,
49
- ""
50
- )
51
- .replace(/ /gu, "-")
52
- );
53
- }
54
-
55
- /**
56
- * Unescapes the text of a String-type micromark Token.
57
- *
58
- * @param {Token} token String-type micromark Token.
59
- * @returns {string} Unescaped token text.
60
- */
61
- function unescapeStringTokenText(token) {
62
- return filterByTypes(token.children, [ "characterEscapeValue", "data" ])
63
- .map((child) => child.text)
64
- .join("");
65
- }
66
-
67
- module.exports = {
68
- "names": [ "MD051", "link-fragments" ],
69
- "description": "Link fragments should be valid",
70
- "tags": [ "links" ],
71
- "function": function MD051(params, onError) {
72
- const { tokens } = params.parsers.micromark;
73
- const fragments = new Map();
74
-
75
- // Process headings
76
- const headingTexts = filterByTypes(
77
- tokens,
78
- [ "atxHeadingText", "setextHeadingText" ]
79
- );
80
- for (const headingText of headingTexts) {
81
- const fragment = convertHeadingToHTMLFragment(headingText);
82
- if (fragment !== "#") {
83
- const count = fragments.get(fragment) || 0;
84
- if (count) {
85
- fragments.set(`${fragment}-${count}`, 0);
86
- }
87
- fragments.set(fragment, count + 1);
88
- let match = null;
89
- while ((match = anchorRe.exec(headingText.text)) !== null) {
90
- const [ , anchor ] = match;
91
- if (!fragments.has(anchor)) {
92
- fragments.set(anchor, 1);
93
- }
94
- }
95
- }
96
- }
97
-
98
- // Process HTML anchors
99
- for (const token of filterByTypes(tokens, [ "htmlText" ])) {
100
- const htmlTagInfo = getHtmlTagInfo(token);
101
- if (htmlTagInfo && !htmlTagInfo.close) {
102
- const anchorMatch = idRe.exec(token.text) ||
103
- (htmlTagInfo.name.toLowerCase() === "a" && nameRe.exec(token.text));
104
- if (anchorMatch && anchorMatch.length > 0) {
105
- fragments.set(`#${anchorMatch[1]}`, 0);
106
- }
107
- }
108
- }
109
-
110
- // Process link and definition fragments
111
- const parentChilds = [
112
- [ "link", "resourceDestinationString" ],
113
- [ "definition", "definitionDestinationString" ]
114
- ];
115
- for (const [ parentType, definitionType ] of parentChilds) {
116
- const links = filterByTypes(tokens, [ parentType ]);
117
- for (const link of links) {
118
- const definitions = filterByTypes(link.children, [ definitionType ]);
119
- for (const definition of definitions) {
120
- const { endColumn, startColumn } = definition;
121
- const text = unescapeStringTokenText(definition);
122
- if (
123
- (text.length > 1) &&
124
- text.startsWith("#") &&
125
- !fragments.has(text) &&
126
- !fragments.has(`#${encodeURIComponent(text.slice(1))}`)
127
- ) {
128
- // eslint-disable-next-line no-undef-init
129
- let context = undefined;
130
- // eslint-disable-next-line no-undef-init
131
- let range = undefined;
132
- // eslint-disable-next-line no-undef-init
133
- let fixInfo = undefined;
134
- if (link.startLine === link.endLine) {
135
- context = link.text;
136
- range = [ link.startColumn, link.endColumn - link.startColumn ];
137
- fixInfo = {
138
- "editColumn": startColumn,
139
- "deleteCount": endColumn - startColumn
140
- };
141
- }
142
- const textLower = text.toLowerCase();
143
- const mixedCaseKey = [ ...fragments.keys() ]
144
- .find((key) => textLower === key.toLowerCase());
145
- if (mixedCaseKey) {
146
- // @ts-ignore
147
- (fixInfo || {}).insertText = mixedCaseKey;
148
- addErrorDetailIf(
149
- onError,
150
- link.startLine,
151
- mixedCaseKey,
152
- text,
153
- undefined,
154
- context,
155
- range,
156
- fixInfo
157
- );
158
- } else {
159
- addError(
160
- onError,
161
- link.startLine,
162
- undefined,
163
- context,
164
- range
165
- );
166
- }
167
- }
168
- }
169
- }
170
- }
171
- }
172
- };
@@ -1,39 +0,0 @@
1
- // @ts-check
2
-
3
- "use strict";
4
-
5
- const { addError } = require("../helpers");
6
- const { referenceLinkImageData } = require("./cache");
7
-
8
- module.exports = {
9
- "names": [ "MD052", "reference-links-images" ],
10
- "description":
11
- "Reference links and images should use a label that is defined",
12
- "tags": [ "images", "links" ],
13
- "function": function MD052(params, onError) {
14
- const { config, lines } = params;
15
- const shortcutSyntax = config.shortcut_syntax || false;
16
- const { definitions, references, shortcuts } = referenceLinkImageData();
17
- const entries = shortcutSyntax ?
18
- [ ...references.entries(), ...shortcuts.entries() ] :
19
- references.entries();
20
- // Look for links/images that use an undefined link reference
21
- for (const reference of entries) {
22
- const [ label, datas ] = reference;
23
- if (!definitions.has(label)) {
24
- for (const data of datas) {
25
- const [ lineIndex, index, length ] = data;
26
- // Context will be incomplete if reporting for a multi-line link
27
- const context = lines[lineIndex].slice(index, index + length);
28
- addError(
29
- onError,
30
- lineIndex + 1,
31
- `Missing link or image reference definition: "${label}"`,
32
- context,
33
- [ index + 1, context.length ]
34
- );
35
- }
36
- }
37
- }
38
- }
39
- };