markdownlint 0.34.0 → 0.36.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 (90) hide show
  1. package/CHANGELOG.md +21 -0
  2. package/README.md +97 -45
  3. package/demo/markdownlint-browser.js +2186 -2164
  4. package/doc/CustomRules.md +66 -255
  5. package/doc/Rules.md +102 -29
  6. package/doc/md003.md +2 -2
  7. package/doc/md004.md +4 -3
  8. package/doc/md034.md +5 -0
  9. package/doc/md035.md +3 -8
  10. package/doc/md044.md +10 -0
  11. package/doc/md046.md +2 -2
  12. package/doc/md048.md +3 -2
  13. package/doc/md049.md +4 -3
  14. package/doc/md050.md +4 -4
  15. package/doc/md051.md +11 -3
  16. package/doc/md055.md +3 -2
  17. package/doc/md058.md +48 -0
  18. package/helpers/README.md +2 -45
  19. package/helpers/helpers.js +115 -607
  20. package/helpers/micromark-helpers.cjs +296 -0
  21. package/helpers/micromark-parse.cjs +313 -0
  22. package/helpers/package.json +5 -2
  23. package/helpers/shared.js +6 -0
  24. package/helpers/test.cjs +28 -0
  25. package/lib/cache.js +62 -13
  26. package/lib/configuration-strict.d.ts +1199 -0
  27. package/lib/configuration.d.ts +3 -1173
  28. package/lib/constants.js +3 -2
  29. package/lib/markdownit.cjs +172 -0
  30. package/lib/markdownlint.d.ts +103 -56
  31. package/lib/markdownlint.js +180 -120
  32. package/lib/md001.js +15 -9
  33. package/lib/md003.js +14 -9
  34. package/lib/md004.js +55 -48
  35. package/lib/md005.js +4 -13
  36. package/lib/md007.js +7 -11
  37. package/lib/md009.js +50 -44
  38. package/lib/md010.js +52 -33
  39. package/lib/md011.js +32 -23
  40. package/lib/md012.js +17 -9
  41. package/lib/md013.js +44 -38
  42. package/lib/md014.js +31 -38
  43. package/lib/md018.js +17 -9
  44. package/lib/md019-md021.js +80 -0
  45. package/lib/md020.js +14 -8
  46. package/lib/md022.js +13 -29
  47. package/lib/md023.js +22 -23
  48. package/lib/md024.js +12 -9
  49. package/lib/md025.js +15 -10
  50. package/lib/md026.js +2 -7
  51. package/lib/md027.js +7 -12
  52. package/lib/md028.js +3 -8
  53. package/lib/md029.js +40 -34
  54. package/lib/md030.js +4 -10
  55. package/lib/md031.js +45 -23
  56. package/lib/md032.js +33 -31
  57. package/lib/md033.js +3 -8
  58. package/lib/md034.js +21 -34
  59. package/lib/md035.js +2 -7
  60. package/lib/md036.js +19 -24
  61. package/lib/md037.js +3 -8
  62. package/lib/md038.js +11 -22
  63. package/lib/md039.js +64 -54
  64. package/lib/md040.js +13 -20
  65. package/lib/md041.js +5 -5
  66. package/lib/md042.js +44 -38
  67. package/lib/md043.js +20 -14
  68. package/lib/md044.js +34 -36
  69. package/lib/md045.js +5 -10
  70. package/lib/md046.js +2 -8
  71. package/lib/md048.js +30 -23
  72. package/lib/md049-md050.js +22 -12
  73. package/lib/md051.js +20 -28
  74. package/lib/md052.js +2 -2
  75. package/lib/md053.js +7 -6
  76. package/lib/md054.js +16 -23
  77. package/lib/md055.js +41 -49
  78. package/lib/md056.js +32 -33
  79. package/lib/md058.js +58 -0
  80. package/lib/rules.js +11 -4
  81. package/package.json +23 -20
  82. package/schema/.markdownlint.jsonc +58 -52
  83. package/schema/.markdownlint.yaml +56 -51
  84. package/schema/ValidatingConfiguration.md +6 -8
  85. package/schema/markdownlint-config-schema-strict.json +1841 -0
  86. package/schema/markdownlint-config-schema.json +141 -109
  87. package/style/prettier.json +1 -0
  88. package/helpers/micromark.cjs +0 -445
  89. package/lib/md019.js +0 -42
  90. package/lib/md021.js +0 -65
package/lib/cache.js CHANGED
@@ -2,20 +2,69 @@
2
2
 
3
3
  "use strict";
4
4
 
5
+ const helpers = require("../helpers");
6
+ const { filterByTypes } = require("../helpers/micromark-helpers.cjs");
7
+
8
+ /** @type {Map<string, object>} */
5
9
  const map = new Map();
10
+ let params = undefined;
11
+
12
+ /**
13
+ * Initializes (resets) the cache.
14
+ *
15
+ * @param {import("./markdownlint").RuleParams} [p] Rule parameters object.
16
+ * @returns {void}
17
+ */
18
+ function initialize(p) {
19
+ map.clear();
20
+ params = p;
21
+ }
6
22
 
7
- module.exports.set = (keyValuePairs) => {
8
- for (const [ key, value ] of Object.entries(keyValuePairs)) {
9
- map.set(key, value);
23
+ /**
24
+ * Gets a cached object value - computes it and caches it.
25
+ *
26
+ * @param {string} name Cache object name.
27
+ * @param {Function} getValue Getter for object value.
28
+ * @returns {Object} Object value.
29
+ */
30
+ function getCached(name, getValue) {
31
+ if (map.has(name)) {
32
+ return map.get(name);
10
33
  }
34
+ const value = getValue();
35
+ map.set(name, value);
36
+ return value;
37
+ }
38
+
39
+ /**
40
+ * Filters a list of Micromark tokens by type and caches the result.
41
+ *
42
+ * @param {import("./markdownlint").MicromarkTokenType[]} types Types to allow.
43
+ * @param {boolean} [htmlFlow] Whether to include htmlFlow content.
44
+ * @returns {import("./markdownlint").MicromarkToken[]} Filtered tokens.
45
+ */
46
+ function filterByTypesCached(types, htmlFlow) {
47
+ return getCached(
48
+ // eslint-disable-next-line prefer-rest-params
49
+ JSON.stringify(arguments),
50
+ () => filterByTypes(params.parsers.micromark.tokens, types, htmlFlow)
51
+ );
52
+ }
53
+
54
+ /**
55
+ * Gets a reference link and image data object.
56
+ *
57
+ * @returns {Object} Reference link and image data object.
58
+ */
59
+ function getReferenceLinkImageData() {
60
+ return getCached(
61
+ getReferenceLinkImageData.name,
62
+ () => helpers.getReferenceLinkImageData(params.parsers.micromark.tokens)
63
+ );
64
+ }
65
+
66
+ module.exports = {
67
+ initialize,
68
+ filterByTypesCached,
69
+ getReferenceLinkImageData
11
70
  };
12
- module.exports.clear = () => map.clear();
13
-
14
- module.exports.codeBlockAndSpanRanges =
15
- () => map.get("codeBlockAndSpanRanges");
16
- module.exports.flattenedLists =
17
- () => map.get("flattenedLists");
18
- module.exports.lineMetadata =
19
- () => map.get("lineMetadata");
20
- module.exports.referenceLinkImageData =
21
- () => map.get("referenceLinkImageData");