markdownlint 0.41.1 → 0.42.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.
- package/CHANGELOG.md +18 -0
- package/CONTRIBUTING.md +62 -77
- package/README.md +7 -7
- package/doc/CustomRules.md +6 -4
- package/doc/Rules.md +76 -35
- package/doc/md010.md +0 -1
- package/doc/md024.md +1 -1
- package/doc/md043.md +47 -9
- package/doc/md051.md +19 -19
- package/doc/md055.md +6 -3
- package/doc/md060.md +3 -2
- package/helpers/README.md +2 -2
- package/helpers/helpers.cjs +16 -7
- package/helpers/micromark-helpers.cjs +7 -10
- package/helpers/package.json +1 -5
- package/lib/configuration-strict.d.ts +124 -112
- package/lib/constants.mjs +1 -1
- package/lib/defer-require.cjs +1 -0
- package/lib/exports.d.mts +29 -1
- package/lib/markdownit.cjs +8 -1
- package/lib/markdownlint.d.mts +337 -195
- package/lib/markdownlint.mjs +78 -85
- package/lib/md007.mjs +2 -2
- package/lib/md009.mjs +2 -3
- package/lib/md010.mjs +1 -1
- package/lib/md011.mjs +10 -7
- package/lib/md012.mjs +1 -1
- package/lib/md013.mjs +13 -9
- package/lib/md018.mjs +1 -1
- package/lib/md020.mjs +1 -1
- package/lib/md022.mjs +5 -6
- package/lib/md025.mjs +1 -1
- package/lib/md027.mjs +1 -1
- package/lib/md028.mjs +1 -2
- package/lib/md029.mjs +1 -2
- package/lib/md030.mjs +4 -4
- package/lib/md031.mjs +1 -1
- package/lib/md033.mjs +1 -1
- package/lib/md034.mjs +1 -1
- package/lib/md039.mjs +5 -1
- package/lib/md041.mjs +1 -1
- package/lib/md043.mjs +98 -44
- package/lib/md044.mjs +2 -2
- package/lib/md048.mjs +1 -3
- package/lib/md051.mjs +2 -3
- package/lib/md055.mjs +11 -1
- package/lib/md056.mjs +1 -1
- package/lib/md058.mjs +1 -1
- package/lib/md060.mjs +24 -4
- package/lib/micromark-parse.mjs +1 -1
- package/lib/resolve-module.d.cts +15 -10
- package/package.json +31 -34
- package/schema/.markdownlint.jsonc +54 -54
- package/schema/.markdownlint.yaml +54 -54
- package/schema/markdownlint-config-schema-strict.json +126 -118
- package/schema/markdownlint-config-schema.json +126 -118
package/doc/md051.md
CHANGED
|
@@ -13,7 +13,7 @@ Parameters:
|
|
|
13
13
|
Fixable: Some violations can be fixed by tooling
|
|
14
14
|
|
|
15
15
|
This rule is triggered when a link fragment does not match any of the fragments
|
|
16
|
-
that are automatically generated for headings in
|
|
16
|
+
that are automatically generated by GitHub for headings in the document:
|
|
17
17
|
|
|
18
18
|
```markdown
|
|
19
19
|
# Heading Name
|
|
@@ -31,8 +31,9 @@ generated name (see below):
|
|
|
31
31
|
```
|
|
32
32
|
|
|
33
33
|
For consistency, this rule requires fragments to exactly match the [GitHub
|
|
34
|
-
|
|
35
|
-
lowercase. Therefore, the following
|
|
34
|
+
algorithm for section links][github-section-links] which (among other things)
|
|
35
|
+
converts letters to lowercase. Therefore, the following is reported as a
|
|
36
|
+
violation:
|
|
36
37
|
|
|
37
38
|
```markdown
|
|
38
39
|
# Heading Name
|
|
@@ -44,9 +45,9 @@ To ignore case when comparing fragments with heading names, the `ignore_case`
|
|
|
44
45
|
parameter can be set to `true`. In this configuration, the previous example is
|
|
45
46
|
not reported as a violation.
|
|
46
47
|
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
48
|
+
Some platforms allow the syntax `{#named-anchor}` to be used within a heading to
|
|
49
|
+
provide a specific name (consisting of only lower-case letters, numbers, `-`,
|
|
50
|
+
and `_`); that is allowed by this rule:
|
|
50
51
|
|
|
51
52
|
```markdown
|
|
52
53
|
# Heading Name {#custom-name}
|
|
@@ -63,8 +64,8 @@ attribute can be used to define a fragment:
|
|
|
63
64
|
[Link](#bookmark)
|
|
64
65
|
```
|
|
65
66
|
|
|
66
|
-
|
|
67
|
-
control over the text of the fragment identifier.
|
|
67
|
+
Using an `a` tag can be useful in scenarios where a heading is not appropriate
|
|
68
|
+
or for control over the text of the fragment identifier.
|
|
68
69
|
|
|
69
70
|
[HTML links to `#top` scroll to the top of a document][html-top-fragment]. This
|
|
70
71
|
rule allows that syntax (using lower-case for consistency):
|
|
@@ -73,16 +74,15 @@ rule allows that syntax (using lower-case for consistency):
|
|
|
73
74
|
[Link](#top)
|
|
74
75
|
```
|
|
75
76
|
|
|
76
|
-
This rule
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
For example, this link to line 20:
|
|
77
|
+
This rule supports the fragment syntax used by GitHub to highlight [specific
|
|
78
|
+
lines/sections of a document][github-linking-to-content]. For example, this link
|
|
79
|
+
to line 20:
|
|
80
80
|
|
|
81
81
|
```markdown
|
|
82
82
|
[Link](#L20)
|
|
83
83
|
```
|
|
84
84
|
|
|
85
|
-
And this link to content starting within line 19 running
|
|
85
|
+
And this link to content starting within line 19 running partly through line 21:
|
|
86
86
|
|
|
87
87
|
```markdown
|
|
88
88
|
[Link](#L19C5-L21C11)
|
|
@@ -91,8 +91,8 @@ And this link to content starting within line 19 running into line 21:
|
|
|
91
91
|
Some Markdown generators dynamically create and insert headings when building
|
|
92
92
|
documents, for example by combining a fixed prefix like `figure-` and an
|
|
93
93
|
incrementing numeric counter. To ignore such generated fragments, set the
|
|
94
|
-
`ignored_pattern` [regular expression][RegEx] parameter to a pattern
|
|
95
|
-
|
|
94
|
+
`ignored_pattern` [regular expression][RegEx] parameter to a suitable pattern
|
|
95
|
+
(e.g., `^figure-`).
|
|
96
96
|
|
|
97
97
|
Rationale: [GitHub section links][github-section-links] are created
|
|
98
98
|
automatically for every heading when Markdown content is displayed on GitHub.
|
|
@@ -101,17 +101,17 @@ However, section links change if headings are renamed or removed. This rule
|
|
|
101
101
|
helps identify broken section links within a document.
|
|
102
102
|
|
|
103
103
|
Note: Section links are **not** part of the CommonMark specification; this rule
|
|
104
|
-
enforces the
|
|
104
|
+
enforces the GitHub algorithm. Basically:
|
|
105
105
|
|
|
106
106
|
1. Convert text to lowercase
|
|
107
107
|
2. Remove punctuation characters
|
|
108
108
|
3. Convert spaces to dashes
|
|
109
|
-
4.
|
|
110
|
-
5.
|
|
109
|
+
4. Remove HTML comments
|
|
110
|
+
5. Append dash+incrementing integer if needed for uniqueness
|
|
111
|
+
6. [URI-encode][encodeURIComponent] the result
|
|
111
112
|
|
|
112
113
|
[encodeURIComponent]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/encodeURIComponent
|
|
113
114
|
[github-section-links]: https://docs.github.com/en/get-started/writing-on-github/getting-started-with-writing-and-formatting-on-github/basic-writing-and-formatting-syntax#section-links
|
|
114
|
-
[github-heading-algorithm]: https://github.com/gjtorikian/html-pipeline/blob/f13a1534cb650ba17af400d1acd3a22c28004c09/lib/html/pipeline/toc_filter.rb
|
|
115
115
|
[github-linking-to-content]: https://docs.github.com/en/get-started/writing-on-github/working-with-advanced-formatting/creating-a-permanent-link-to-a-code-snippet#linking-to-markdown
|
|
116
116
|
[html-top-fragment]: https://html.spec.whatwg.org/multipage/browsing-the-web.html#scrolling-to-a-fragment
|
|
117
117
|
[RegEx]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_expressions
|
package/doc/md055.md
CHANGED
|
@@ -8,15 +8,18 @@ Parameters:
|
|
|
8
8
|
|
|
9
9
|
- `style`: Table pipe style (`string`, default `consistent`, values
|
|
10
10
|
`consistent` / `leading_and_trailing` / `leading_only` /
|
|
11
|
-
`no_leading_or_trailing` / `trailing_only`)
|
|
11
|
+
`no_leading_or_trailing` / `per_table` / `trailing_only`)
|
|
12
12
|
|
|
13
13
|
This rule is triggered when a [GitHub Flavored Markdown table][gfm-table-055]
|
|
14
|
-
is inconsistent
|
|
14
|
+
is inconsistent with 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
17
|
is used to determine the style that is enforced for every table in the document.
|
|
18
18
|
A specific style can be used instead (`leading_and_trailing`, `leading_only`,
|
|
19
|
-
`no_leading_or_trailing`, `trailing_only`)
|
|
19
|
+
`no_leading_or_trailing`, `trailing_only`) to require all tables in a document
|
|
20
|
+
have the same approach. The style `per_table` can be used to require the rows of
|
|
21
|
+
each table use the same approach (based on its header row) while allowing tables
|
|
22
|
+
in a document to differ from each other.
|
|
20
23
|
|
|
21
24
|
This table's header row has leading and trailing pipes, but its delimiter row is
|
|
22
25
|
missing the trailing pipe and its first row of cells is missing the leading
|
package/doc/md060.md
CHANGED
|
@@ -35,7 +35,8 @@ The `aligned` style ignores cell content, so the following is also valid:
|
|
|
35
35
|
| N | No |
|
|
36
36
|
```
|
|
37
37
|
|
|
38
|
-
Style `compact` avoids extra padding with a single space
|
|
38
|
+
Style `compact` avoids extra padding with a single space before and after cell
|
|
39
|
+
content (or just a single space for cells without content):
|
|
39
40
|
|
|
40
41
|
```markdown
|
|
41
42
|
| Character | Meaning |
|
|
@@ -44,7 +45,7 @@ Style `compact` avoids extra padding with a single space around cell content:
|
|
|
44
45
|
| N | No |
|
|
45
46
|
```
|
|
46
47
|
|
|
47
|
-
Style `tight` uses no padding at all for
|
|
48
|
+
Style `tight` uses no padding at all (for cells with or without content):
|
|
48
49
|
|
|
49
50
|
```markdown
|
|
50
51
|
|Character|Meaning|
|
package/helpers/README.md
CHANGED
|
@@ -22,8 +22,8 @@ be useful to custom rule authors and may avoid duplicating code.
|
|
|
22
22
|
*None* - The entire body of code is tested to 100% coverage by the core
|
|
23
23
|
`markdownlint` project, so there are no additional tests here.
|
|
24
24
|
|
|
25
|
-
[custom-rules]: https://github.com/DavidAnson/markdownlint/blob/v0.
|
|
25
|
+
[custom-rules]: https://github.com/DavidAnson/markdownlint/blob/v0.42.0/doc/CustomRules.md
|
|
26
26
|
[jsdoc]: https://wikipedia.org/wiki/JSDoc
|
|
27
27
|
[markdown]: https://wikipedia.org/wiki/Markdown
|
|
28
28
|
[markdownlint]: https://github.com/DavidAnson/markdownlint
|
|
29
|
-
[rules]: https://github.com/DavidAnson/markdownlint/blob/v0.
|
|
29
|
+
[rules]: https://github.com/DavidAnson/markdownlint/blob/v0.42.0/doc/Rules.md
|
package/helpers/helpers.cjs
CHANGED
|
@@ -2,8 +2,6 @@
|
|
|
2
2
|
|
|
3
3
|
"use strict";
|
|
4
4
|
|
|
5
|
-
/* eslint-disable unicorn/comment-content */
|
|
6
|
-
|
|
7
5
|
const micromark = require("./micromark-helpers.cjs");
|
|
8
6
|
const { newlineRe, nextLinesRe } = require("./shared.cjs");
|
|
9
7
|
|
|
@@ -14,14 +12,14 @@ module.exports.nextLinesRe = nextLinesRe;
|
|
|
14
12
|
/** @typedef {import("../lib/exports.mjs").RuleOnErrorFixInfo} RuleOnErrorFixInfo */
|
|
15
13
|
/** @typedef {import("../lib/exports.mjs").MicromarkToken} MicromarkToken */
|
|
16
14
|
// eslint-disable-next-line jsdoc/valid-types
|
|
17
|
-
/** @typedef {import("micromark-extension-gfm-footnote", { with: { "resolution-mode": "import" } })} */
|
|
15
|
+
/** @typedef {typeof import("micromark-extension-gfm-footnote", { with: { "resolution-mode": "import" } })} _ambient_ */
|
|
18
16
|
// eslint-disable-next-line jsdoc/valid-types
|
|
19
|
-
/** @typedef {import("../lib/micromark-types.d.mts", { with: { "resolution-mode": "import" } })} */
|
|
17
|
+
/** @typedef {typeof import("../lib/micromark-types.d.mts", { with: { "resolution-mode": "import" } })} _ambient_2_ */
|
|
20
18
|
|
|
21
19
|
// Regular expression for matching common front matter (YAML and TOML)
|
|
22
|
-
//
|
|
20
|
+
// Potential for regular expression denial of service is mitigated at point-of-use via "re2js" package
|
|
23
21
|
module.exports.frontMatterRe =
|
|
24
|
-
// eslint-disable-next-line unicorn/prefer-unicode-code-point-escapes
|
|
22
|
+
// eslint-disable-next-line redos/no-vulnerable, unicorn/prefer-unicode-code-point-escapes
|
|
25
23
|
/((^---[^\S\r\n\u2028\u2029]*$[\s\S]+?^---\s*)|(^\+\+\+[^\S\r\n\u2028\u2029]*$[\s\S]+?^(\+\+\+|\.\.\.)\s*)|(^\{[^\S\r\n\u2028\u2029]*$[\s\S]+?^\}\s*))(\r\n|\r|\n|$)/m;
|
|
26
24
|
|
|
27
25
|
// Regular expression for matching the start of inline disable/enable comments
|
|
@@ -44,6 +42,17 @@ module.exports.allPunctuation = allPunctuation;
|
|
|
44
42
|
// All punctuation characters without question mark (normal and full-width)
|
|
45
43
|
module.exports.allPunctuationNoQuestion = allPunctuation.replace(/[??]/gu, "");
|
|
46
44
|
|
|
45
|
+
/**
|
|
46
|
+
* Returns true iff the input is a Boolean.
|
|
47
|
+
*
|
|
48
|
+
* @param {Object} obj Object of unknown type.
|
|
49
|
+
* @returns {boolean} True iff obj is a Boolean.
|
|
50
|
+
*/
|
|
51
|
+
function isBoolean(obj) {
|
|
52
|
+
return typeof obj === "boolean";
|
|
53
|
+
}
|
|
54
|
+
module.exports.isBoolean = isBoolean;
|
|
55
|
+
|
|
47
56
|
/**
|
|
48
57
|
* Returns true iff the input is a Number.
|
|
49
58
|
*
|
|
@@ -179,7 +188,7 @@ const safeCommentCharacter = ".";
|
|
|
179
188
|
const startsWithPipeRe = /^ *\|/;
|
|
180
189
|
const notCrLfRe = /[^\r\n]/g;
|
|
181
190
|
const notSpaceCrLfRe = /[^ \r\n]/g;
|
|
182
|
-
const trailingSpaceRe = / +[\r\n]/g;
|
|
191
|
+
const trailingSpaceRe = /(?<=^|[^ ]) +[\r\n]/g;
|
|
183
192
|
// eslint-disable-next-line unicorn/no-unsafe-string-replacement
|
|
184
193
|
const replaceTrailingSpace = (/** @type {string} */ s) => s.replace(notCrLfRe, safeCommentCharacter);
|
|
185
194
|
module.exports.clearHtmlCommentText = function clearHtmlCommentText(/** @type {string} */ text) {
|
|
@@ -8,7 +8,7 @@ const { flatTokensSymbol, htmlFlowSymbol, newlineRe } = require("./shared.cjs");
|
|
|
8
8
|
/** @typedef {import("micromark-util-types", { with: { "resolution-mode": "import" } }).TokenType} TokenType */
|
|
9
9
|
/** @typedef {import("../lib/exports.mjs").MicromarkToken} Token */
|
|
10
10
|
// eslint-disable-next-line jsdoc/valid-types
|
|
11
|
-
/** @typedef {import("../lib/micromark-types.d.mts", { with: { "resolution-mode": "import" } })} */
|
|
11
|
+
/** @typedef {typeof import("../lib/micromark-types.d.mts", { with: { "resolution-mode": "import" } })} _ambient_ */
|
|
12
12
|
|
|
13
13
|
/**
|
|
14
14
|
* Determines if a Micromark token is within an htmlFlow type.
|
|
@@ -131,10 +131,9 @@ function filterByTypes(tokens, types, htmlFlow) {
|
|
|
131
131
|
const flatTokens =
|
|
132
132
|
// @ts-ignore
|
|
133
133
|
tokens[flatTokensSymbol];
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
return filterByPredicate(tokens, predicate);
|
|
134
|
+
return flatTokens ?
|
|
135
|
+
flatTokens.filter(predicate) :
|
|
136
|
+
filterByPredicate(tokens, predicate);
|
|
138
137
|
}
|
|
139
138
|
|
|
140
139
|
/**
|
|
@@ -205,10 +204,7 @@ function getHeadingStyle(heading) {
|
|
|
205
204
|
const atxHeadingSequenceLength = heading.children.filter(
|
|
206
205
|
(child) => child.type === "atxHeadingSequence"
|
|
207
206
|
).length;
|
|
208
|
-
|
|
209
|
-
return "atx";
|
|
210
|
-
}
|
|
211
|
-
return "atx_closed";
|
|
207
|
+
return (atxHeadingSequenceLength === 1) ? "atx" : "atx_closed";
|
|
212
208
|
}
|
|
213
209
|
|
|
214
210
|
/**
|
|
@@ -222,7 +218,8 @@ function getHeadingText(heading) {
|
|
|
222
218
|
.flatMap((descendant) => descendant.children.filter((child) => child.type !== "htmlText"))
|
|
223
219
|
.map((data) => data.text)
|
|
224
220
|
.join("")
|
|
225
|
-
.replace(newlineRe, " ")
|
|
221
|
+
.replace(newlineRe, " ")
|
|
222
|
+
.trim();
|
|
226
223
|
}
|
|
227
224
|
|
|
228
225
|
/**
|
package/helpers/package.json
CHANGED
|
@@ -10,11 +10,7 @@
|
|
|
10
10
|
"author": "David Anson (https://dlaa.me/)",
|
|
11
11
|
"license": "MIT",
|
|
12
12
|
"homepage": "https://github.com/DavidAnson/markdownlint",
|
|
13
|
-
"repository":
|
|
14
|
-
"type": "git",
|
|
15
|
-
"url": "git+https://github.com/DavidAnson/markdownlint.git"
|
|
16
|
-
},
|
|
17
|
-
"bugs": "https://github.com/DavidAnson/markdownlint/issues",
|
|
13
|
+
"repository": "github:DavidAnson/markdownlint",
|
|
18
14
|
"funding": "https://github.com/sponsors/DavidAnson",
|
|
19
15
|
"engines": {
|
|
20
16
|
"node": ">=22"
|