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.
@@ -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
- - `function` is a required synchronous `Function` that implements the rule and is passed two parameters:
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
- - `details` is an optional `String` with information about what caused the error.
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/master/packages/docs-linting/markdownlint-custom-rules)
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/master/scripts/lint-markdown.js)
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
 
@@ -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
+ ```