markdownlint 0.22.0 → 0.25.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/CONTRIBUTING.md +13 -3
- package/LICENSE +1 -1
- package/README.md +140 -83
- package/demo/markdownlint-browser.js +1599 -3309
- package/doc/CustomRules.md +15 -4
- package/doc/Prettier.md +23 -0
- package/doc/Rules.md +191 -80
- package/helpers/LICENSE +1 -1
- package/helpers/helpers.js +260 -68
- package/helpers/package.json +1 -1
- package/lib/cache.js +14 -5
- package/lib/constants.js +7 -0
- package/lib/markdownlint.d.ts +31 -11
- package/lib/markdownlint.js +336 -254
- package/lib/md002.js +1 -1
- package/lib/md004.js +46 -13
- package/lib/md006.js +1 -1
- package/lib/md007.js +4 -2
- package/lib/md009.js +24 -20
- package/lib/md010.js +25 -16
- package/lib/md011.js +31 -27
- package/lib/md018.js +1 -1
- package/lib/md019.js +1 -1
- package/lib/md020.js +1 -1
- package/lib/md021.js +1 -1
- package/lib/md023.js +1 -1
- package/lib/md025.js +1 -1
- package/lib/md032.js +2 -2
- package/lib/md033.js +12 -8
- package/lib/md035.js +4 -4
- package/lib/md037.js +40 -12
- package/lib/md039.js +4 -3
- package/lib/md041.js +14 -3
- package/lib/md043.js +9 -5
- package/lib/md044.js +54 -71
- package/lib/md049.js +45 -0
- package/lib/md050.js +45 -0
- package/lib/rules.js +6 -5
- package/package.json +46 -37
- package/schema/.markdownlint.jsonc +266 -0
- package/schema/.markdownlint.yaml +239 -0
- package/schema/markdownlint-config-schema.json +129 -22
- package/schema/build-config-schema.js +0 -417
package/doc/CustomRules.md
CHANGED
|
@@ -41,7 +41,8 @@ A rule is implemented as an `Object` with one optional and four required propert
|
|
|
41
41
|
- `description` is a required `String` value that describes the rule in output messages.
|
|
42
42
|
- `information` is an optional (absolute) `URL` of a link to more information about the rule.
|
|
43
43
|
- `tags` is a required `Array` of `String` values that groups related rules for easier customization.
|
|
44
|
-
- `
|
|
44
|
+
- `asynchronous` is an optional `Boolean` value that indicates whether the rule returns a `Promise` and runs asynchronously.
|
|
45
|
+
- `function` is a required `Function` that implements the rule and is passed two parameters:
|
|
45
46
|
- `params` is an `Object` with properties that describe the content being analyzed:
|
|
46
47
|
- `name` is a `String` that identifies the input file/string.
|
|
47
48
|
- `tokens` is an `Array` of [`markdown-it` `Token` objects](https://markdown-it.github.io/markdown-it/#Token)
|
|
@@ -51,7 +52,7 @@ A rule is implemented as an `Object` with one optional and four required propert
|
|
|
51
52
|
- `config` is an `Object` corresponding to the rule's entry in `options.config` (if present).
|
|
52
53
|
- `onError` is a function that takes a single `Object` parameter with one required and four optional properties:
|
|
53
54
|
- `lineNumber` is a required `Number` specifying the 1-based line number of the error.
|
|
54
|
-
- `
|
|
55
|
+
- `detail` is an optional `String` with information about what caused the error.
|
|
55
56
|
- `context` is an optional `String` with relevant text surrounding the error location.
|
|
56
57
|
- `range` is an optional `Array` with two `Number` values identifying the 1-based column and length of the error.
|
|
57
58
|
- `fixInfo` is an optional `Object` with information about how to fix the error (all properties are optional, but
|
|
@@ -66,15 +67,25 @@ A rule is implemented as an `Object` with one optional and four required propert
|
|
|
66
67
|
The collection of helper functions shared by the built-in rules is available for use by custom rules in the
|
|
67
68
|
[markdownlint-rule-helpers package](https://www.npmjs.com/package/markdownlint-rule-helpers).
|
|
68
69
|
|
|
70
|
+
### Asynchronous Rules
|
|
71
|
+
|
|
72
|
+
If a rule needs to perform asynchronous operations (such as fetching a network resource), it can specify the value `true` for its `asynchronous` property.
|
|
73
|
+
Asynchronous rules should return a `Promise` from their `function` implementation that is resolved when the rule completes.
|
|
74
|
+
(The value passed to `resolve(...)` is ignored.)
|
|
75
|
+
Linting violations from asynchronous rules are reported via the `onError` function just like for synchronous rules.
|
|
76
|
+
|
|
77
|
+
**Note**: Asynchronous rules cannot be referenced in a synchronous calling context (i.e., `markdownlint.sync(...)`).
|
|
78
|
+
Attempting to do so throws an exception.
|
|
79
|
+
|
|
69
80
|
## Examples
|
|
70
81
|
|
|
71
82
|
- [Simple rules used by the project's test cases](../test/rules)
|
|
72
83
|
- [Code for all `markdownlint` built-in rules](../lib)
|
|
73
84
|
- [Package configuration for publishing to npm](../test/rules/npm)
|
|
74
85
|
- Packages should export a single rule object or an `Array` of rule objects
|
|
75
|
-
- [Custom rules from the Microsoft/vscode-docs-authoring repository](https://github.com/microsoft/vscode-docs-authoring/tree/
|
|
86
|
+
- [Custom rules from the Microsoft/vscode-docs-authoring repository](https://github.com/microsoft/vscode-docs-authoring/tree/main/packages/docs-linting/markdownlint-custom-rules)
|
|
76
87
|
- [Custom rules from the axibase/docs-util repository](https://github.com/axibase/docs-util/tree/master/linting-rules)
|
|
77
|
-
- [Custom rules from the webhintio/hint repository](https://github.com/webhintio/hint/blob/
|
|
88
|
+
- [Custom rules from the webhintio/hint repository](https://github.com/webhintio/hint/blob/main/scripts/lint-markdown.js)
|
|
78
89
|
|
|
79
90
|
## References
|
|
80
91
|
|
package/doc/Prettier.md
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
# Using markdownlint with Prettier
|
|
2
|
+
|
|
3
|
+
[`Prettier`](https://prettier.io) is a popular code formatter. For the most part,
|
|
4
|
+
it works seamlessly with `markdownlint`. Special situations are documented
|
|
5
|
+
below.
|
|
6
|
+
|
|
7
|
+
## List item indentation
|
|
8
|
+
|
|
9
|
+
The default settings of `markdownlint` and `Prettier` are compatible and don't
|
|
10
|
+
result in any linting violations. If `Prettier` is used with `--tab-width` set
|
|
11
|
+
to `4`, the following `markdownlint` configuration can be used:
|
|
12
|
+
|
|
13
|
+
```json
|
|
14
|
+
{
|
|
15
|
+
"MD007": {
|
|
16
|
+
"indent": 4
|
|
17
|
+
},
|
|
18
|
+
"MD030": {
|
|
19
|
+
"ul_single": 3,
|
|
20
|
+
"ul_multi": 3
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
```
|