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/doc/md035.md CHANGED
@@ -23,8 +23,7 @@ in the document:
23
23
  ****
24
24
  ```
25
25
 
26
- To fix this, ensure any horizontal rules used in the document are consistent,
27
- or match the given style if the rule is so configured:
26
+ To fix this, use the same horizontal rule everywhere:
28
27
 
29
28
  ```markdown
30
29
  ---
@@ -32,11 +31,7 @@ or match the given style if the rule is so configured:
32
31
  ---
33
32
  ```
34
33
 
35
- Note: by default, this rule is configured to just require that all horizontal
36
- rules in the document are the same and will trigger if any of the horizontal
37
- rules are different than the first one encountered in the document. If you
38
- want to configure the rule to match a specific style, the parameter given to
39
- the 'style' option is a string containing the exact horizontal rule text that
40
- is allowed.
34
+ The configured style can ensure all horizontal rules use a specific string or it
35
+ can ensure all horizontal rules match the first horizontal rule (`consistent`).
41
36
 
42
37
  Rationale: Consistent formatting makes it easier to understand a document.
package/doc/md044.md CHANGED
@@ -27,6 +27,16 @@ enforce the proper capitalization, specify the desired letter case in the
27
27
  ]
28
28
  ```
29
29
 
30
+ Sometimes a proper name is capitalized differently in certain contexts. In such
31
+ cases, add both forms to the `names` array:
32
+
33
+ ```json
34
+ [
35
+ "GitHub",
36
+ "github.com"
37
+ ]
38
+ ```
39
+
30
40
  Set the `code_blocks` parameter to `false` to disable this rule for code blocks
31
41
  and spans. Set the `html_elements` parameter to `false` to disable this rule
32
42
  for HTML elements and attributes (such as when using a proper name as part of
package/doc/md046.md CHANGED
@@ -34,7 +34,7 @@ document:
34
34
  To fix violations of this rule, use a consistent style (either indenting or code
35
35
  fences).
36
36
 
37
- The specified style can be specific (`fenced`, `indented`) or simply require
38
- that usage be consistent within the document (`consistent`).
37
+ The configured code block style can be specific (`fenced`, `indented`) or can
38
+ require all code blocks match the first code block (`consistent`).
39
39
 
40
40
  Rationale: Consistent formatting makes it easier to understand a document.
package/doc/md048.md CHANGED
@@ -35,7 +35,8 @@ document:
35
35
  ```
36
36
  ````
37
37
 
38
- The configured list style can be a specific symbol to use (backtick, tilde), or
39
- can require that usage be consistent within the document.
38
+ The configured code fence style can be a specific symbol to use (`backtick`,
39
+ `tilde`) or it can require all code fences match the first code fence
40
+ (`consistent`).
40
41
 
41
42
  Rationale: Consistent formatting makes it easier to understand a document.
package/doc/md049.md CHANGED
@@ -26,10 +26,11 @@ To fix this issue, use the configured emphasis style throughout the document:
26
26
  *Text*
27
27
  ```
28
28
 
29
- The configured emphasis style can be a specific symbol to use ("asterisk",
30
- "underscore"), or can require that usage be consistent within the document.
29
+ The configured emphasis style can be a specific symbol to use (`asterisk`,
30
+ `underscore`) or can require all emphasis matches the first emphasis
31
+ (`consistent`).
31
32
 
32
- Note: Emphasis within a word is restricted to "asterisk" in order to avoid
33
+ Note: Emphasis within a word is restricted to `asterisk` in order to avoid
33
34
  unwanted emphasis for words containing internal underscores like_this_one.
34
35
 
35
36
  Rationale: Consistent formatting makes it easier to understand a document.
package/doc/md050.md CHANGED
@@ -26,10 +26,10 @@ To fix this issue, use the configured strong style throughout the document:
26
26
  **Text**
27
27
  ```
28
28
 
29
- The configured strong style can be a specific symbol to use ("asterisk",
30
- "underscore"), or can require that usage be consistent within the document.
29
+ The configured strong style can be a specific symbol to use (`asterisk`,
30
+ `underscore`) or can require all strong matches the first strong (`consistent`).
31
31
 
32
- Note: Emphasis within a word is restricted to "asterisk" in order to avoid
33
- unwanted emphasis for words containing internal underscores like_this_one.
32
+ Note: Emphasis within a word is restricted to `asterisk` in order to avoid
33
+ unwanted emphasis for words containing internal underscores like__this__one.
34
34
 
35
35
  Rationale: Consistent formatting makes it easier to understand a document.
package/doc/md051.md CHANGED
@@ -4,6 +4,10 @@ Tags: `links`
4
4
 
5
5
  Aliases: `link-fragments`
6
6
 
7
+ Parameters:
8
+
9
+ - `ignore_case`: Ignore case of fragments (`boolean`, default `false`)
10
+
7
11
  Fixable: Some violations can be fixed by tooling
8
12
 
9
13
  This rule is triggered when a link fragment does not match any of the fragments
@@ -24,9 +28,9 @@ generated name (see below):
24
28
  [Link](#heading-name)
25
29
  ```
26
30
 
27
- Link fragments may be handled case-sensitively, so this rule requires fragments
28
- to exactly match the [GitHub heading algorithm][github-heading-algorithm].
29
- Therefore, the following example is reported as a violation:
31
+ For consistency, this rule requires fragments to exactly match the [GitHub
32
+ heading algorithm][github-heading-algorithm] which converts letters to
33
+ lowercase. Therefore, the following example is reported as a violation:
30
34
 
31
35
  ```markdown
32
36
  # Heading Name
@@ -34,6 +38,10 @@ Therefore, the following example is reported as a violation:
34
38
  [Link](#Heading-Name)
35
39
  ```
36
40
 
41
+ To ignore case when comparing fragments with heading names, the `ignore_case`
42
+ parameter can be set to `true`. In this configuration, the previous example is
43
+ not reported as a violation.
44
+
37
45
  Alternatively, some platforms allow the syntax `{#named-anchor}` to be used
38
46
  within a heading to provide a specific name (consisting of only lower-case
39
47
  letters, numbers, `-`, and `_`):
package/doc/md055.md CHANGED
@@ -14,8 +14,9 @@ This rule is triggered when a [GitHub Flavored Markdown table][gfm-table-055]
14
14
  is inconsistent about its use of leading and trailing pipe characters (`|`).
15
15
 
16
16
  By default (`consistent` style), the header row of the first table in a document
17
- is used to determine the style that is enforced for all tables in that document.
18
- A specific style can be required by setting the `style` parameter accordingly.
17
+ is used to determine the style that is enforced for every table in the document.
18
+ A specific style can be used instead (`leading_and_trailing`, `leading_only`,
19
+ `no_leading_or_trailing`, `trailing_only`).
19
20
 
20
21
  This table's header row has leading and trailing pipes, but its delimiter row is
21
22
  missing the trailing pipe and its first row of cells is missing the leading
package/doc/md058.md ADDED
@@ -0,0 +1,48 @@
1
+ # `MD058` - Tables should be surrounded by blank lines
2
+
3
+ Tags: `table`
4
+
5
+ Aliases: `blanks-around-tables`
6
+
7
+ Fixable: Some violations can be fixed by tooling
8
+
9
+ This rule is triggered when tables are either not preceded or not followed by a
10
+ blank line:
11
+
12
+ ```markdown
13
+ Some text
14
+ | Header | Header |
15
+ | ------ | ------ |
16
+ | Cell | Cell |
17
+ > Blockquote
18
+ ```
19
+
20
+ To fix violations of this rule, ensure that all tables have a blank line both
21
+ before and after (except when the table is at the very beginning or end of the
22
+ document):
23
+
24
+ ```markdown
25
+ Some text
26
+
27
+ | Header | Header |
28
+ | ------ | ------ |
29
+ | Cell | Cell |
30
+
31
+ > Blockquote
32
+ ```
33
+
34
+ Note that text immediately following a table (i.e., not separated by an empty
35
+ line) is treated as part of the table (per the specification) and will not
36
+ trigger this rule:
37
+
38
+ ```markdown
39
+ | Header | Header |
40
+ | ------ | ------ |
41
+ | Cell | Cell |
42
+ This text is part of the table and the next line is blank
43
+
44
+ Some text
45
+ ```
46
+
47
+ Rationale: In addition to aesthetic reasons, some parsers will incorrectly parse
48
+ tables that don't have blank lines before and after them.
package/helpers/README.md CHANGED
@@ -17,56 +17,13 @@ change from release to release. There are brief descriptive comments above each
17
17
  function, but no [JSDoc][jsdoc] annotations. That said, some of what's here will
18
18
  be useful to custom rule authors and may avoid duplicating code.
19
19
 
20
- ## Examples
21
-
22
- ### Using Helpers from a Custom Rule
23
-
24
- ```javascript
25
- const { forEachLine, getLineMetadata } = require("markdownlint-rule-helpers");
26
-
27
- /** @type import("markdownlint").Rule */
28
- module.exports = {
29
- "names": [ "every-n-lines" ],
30
- "description": "Rule that reports an error every N lines",
31
- "tags": [ "test" ],
32
- "parser": "none",
33
- "function": (params, onError) => {
34
- const n = params.config.n || 2;
35
- forEachLine(getLineMetadata(params), (line, lineIndex) => {
36
- const lineNumber = lineIndex + 1;
37
- if ((lineNumber % n) === 0) {
38
- onError({
39
- "lineNumber": lineNumber,
40
- "detail": "Line number " + lineNumber
41
- });
42
- }
43
- });
44
- }
45
- };
46
- ```
47
-
48
- ### Applying Recommended Fixes
49
-
50
- ```javascript
51
- const { "sync": markdownlintSync } = require("markdownlint");
52
- const markdownlintRuleHelpers = require("markdownlint-rule-helpers");
53
-
54
- function fixMarkdownlintViolations(content) {
55
- const fixResults = markdownlintSync({ strings: { content } });
56
- return markdownlintRuleHelpers.applyFixes(content, fixResults.content);
57
- }
58
- ```
59
-
60
- See also: [`markdownlint` built-in rule implementations][lib].
61
-
62
20
  ## Tests
63
21
 
64
22
  *None* - The entire body of code is tested to 100% coverage by the core
65
23
  `markdownlint` project, so there are no additional tests here.
66
24
 
67
- [custom-rules]: https://github.com/DavidAnson/markdownlint/blob/v0.34.0/doc/CustomRules.md
25
+ [custom-rules]: https://github.com/DavidAnson/markdownlint/blob/v0.36.0/doc/CustomRules.md
68
26
  [jsdoc]: https://en.m.wikipedia.org/wiki/JSDoc
69
- [lib]: https://github.com/DavidAnson/markdownlint/tree/v0.34.0/lib
70
27
  [markdown]: https://en.wikipedia.org/wiki/Markdown
71
28
  [markdownlint]: https://github.com/DavidAnson/markdownlint
72
- [rules]: https://github.com/DavidAnson/markdownlint/blob/v0.34.0/doc/Rules.md
29
+ [rules]: https://github.com/DavidAnson/markdownlint/blob/v0.36.0/doc/Rules.md