markdownlint 0.20.0 → 0.20.4

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 (64) hide show
  1. package/CONTRIBUTING.md +47 -47
  2. package/LICENSE +21 -21
  3. package/README.md +881 -868
  4. package/demo/markdownlint-browser.js +5438 -5306
  5. package/doc/CustomRules.md +313 -313
  6. package/doc/Rules.md +1847 -1795
  7. package/helpers/LICENSE +21 -21
  8. package/helpers/README.md +50 -50
  9. package/helpers/helpers.js +687 -627
  10. package/helpers/package.json +18 -18
  11. package/lib/cache.js +24 -24
  12. package/lib/markdownlint.d.ts +352 -352
  13. package/lib/markdownlint.js +1101 -1101
  14. package/lib/md001.js +22 -22
  15. package/lib/md002.js +22 -22
  16. package/lib/md003.js +42 -42
  17. package/lib/md004.js +43 -43
  18. package/lib/md005.js +69 -69
  19. package/lib/md006.js +34 -34
  20. package/lib/md007.js +47 -47
  21. package/lib/md009.js +77 -77
  22. package/lib/md010.js +38 -38
  23. package/lib/md011.js +38 -38
  24. package/lib/md012.js +32 -32
  25. package/lib/md013.js +99 -99
  26. package/lib/md014.js +53 -53
  27. package/lib/md018.js +34 -34
  28. package/lib/md019.js +39 -39
  29. package/lib/md020.js +62 -62
  30. package/lib/md021.js +60 -60
  31. package/lib/md022.js +56 -56
  32. package/lib/md023.js +38 -38
  33. package/lib/md024.js +38 -38
  34. package/lib/md025.js +32 -32
  35. package/lib/md026.js +40 -40
  36. package/lib/md027.js +56 -56
  37. package/lib/md028.js +38 -38
  38. package/lib/md029.js +66 -66
  39. package/lib/md030.js +50 -50
  40. package/lib/md031.js +39 -39
  41. package/lib/md032.js +50 -50
  42. package/lib/md033.js +45 -45
  43. package/lib/md034.js +61 -61
  44. package/lib/md035.js +21 -21
  45. package/lib/md036.js +56 -56
  46. package/lib/md037.js +150 -89
  47. package/lib/md038.js +68 -68
  48. package/lib/md039.js +64 -64
  49. package/lib/md040.js +18 -18
  50. package/lib/md041.js +31 -31
  51. package/lib/md042.js +41 -41
  52. package/lib/md043.js +45 -45
  53. package/lib/md044.js +77 -71
  54. package/lib/md045.js +18 -18
  55. package/lib/md046.js +32 -32
  56. package/lib/md047.js +28 -28
  57. package/lib/md048.js +29 -29
  58. package/lib/rules.js +61 -61
  59. package/package.json +73 -67
  60. package/schema/build-config-schema.js +405 -405
  61. package/schema/markdownlint-config-schema.json +1550 -1550
  62. package/style/all.json +5 -5
  63. package/style/cirosantilli.json +22 -22
  64. package/style/relaxed.json +13 -13
@@ -1,313 +1,313 @@
1
- # Custom Rules
2
-
3
- In addition to its built-in rules, `markdownlint` lets you enhance the linting experience by passing a list of custom rules using the [`options.customRules` property](../README.md#optionscustomrules).
4
- Custom rules can do everything the built-in rules can and are defined inline or imported from another package ([keyword `markdownlint-rule` on npm](https://www.npmjs.com/search?q=keywords:markdownlint-rule)).
5
- Custom rules can be disabled, enabled, and customized using the same syntax as built-in rules.
6
-
7
- ## Authoring
8
-
9
- Rules are defined by a name (or multiple names), a description, an optional link to more information, one or more tags, and a function that implements the rule's behavior.
10
- That function is called once for each file/string input and is passed the parsed input and a function to log any violations.
11
-
12
- A simple rule implementation looks like:
13
-
14
- ```js
15
- const { URL } = require("url");
16
-
17
- module.exports = {
18
- "names": [ "any-blockquote" ],
19
- "description": "Rule that reports an error for any blockquote",
20
- "information": new URL("https://example.com/rules/any-blockquote"),
21
- "tags": [ "test" ],
22
- "function": function rule(params, onError) {
23
- params.tokens.filter(function filterToken(token) {
24
- return token.type === "blockquote_open";
25
- }).forEach(function forToken(blockquote) {
26
- var lines = blockquote.map[1] - blockquote.map[0];
27
- onError({
28
- "lineNumber": blockquote.lineNumber,
29
- "detail": "Blockquote spans " + lines + " line(s).",
30
- "context": blockquote.line.substr(0, 7)
31
- });
32
- });
33
- }
34
- };
35
- ```
36
-
37
- A rule is implemented as an `Object` with one optional and four required properties:
38
-
39
- - `names` is a required `Array` of `String` values that identify the rule in output messages and config.
40
- - `description` is a required `String` value that describes the rule in output messages.
41
- - `information` is an optional (absolute) `URL` of a link to more information about the rule.
42
- - `tags` is a required `Array` of `String` values that groups related rules for easier customization.
43
- - `function` is a required synchronous `Function` that implements the rule and is passed two parameters:
44
- - `params` is an `Object` with properties that describe the content being analyzed:
45
- - `name` is a `String` that identifies the input file/string.
46
- - `tokens` is an `Array` of [`markdown-it` `Token` objects](https://markdown-it.github.io/markdown-it/#Token)
47
- with added `line` and `lineNumber` properties.
48
- - `lines` is an `Array` of `String` values corresponding to the lines of the input file/string.
49
- - `frontMatterLines` is an `Array` of `String` values corresponding to any front matter (not present in `lines`).
50
- - `config` is an `Object` corresponding to the rule's entry in `options.config` (if present).
51
- - `onError` is a function that takes a single `Object` parameter with one required and four optional properties:
52
- - `lineNumber` is a required `Number` specifying the 1-based line number of the error.
53
- - `details` is an optional `String` with information about what caused the error.
54
- - `context` is an optional `String` with relevant text surrounding the error location.
55
- - `range` is an optional `Array` with two `Number` values identifying the 1-based column and length of the error.
56
- - `fixInfo` is an optional `Object` with information about how to fix the error (all properties are optional, but
57
- at least one of `deleteCount` and `insertText` should be present; when applying a fix, the delete should be
58
- performed before the insert):
59
- - `lineNumber` is an optional `Number` specifying the 1-based line number of the edit.
60
- - `editColumn` is an optional `Number` specifying the 1-based column number of the edit.
61
- - `deleteCount` is an optional `Number` specifying the count of characters to delete.
62
- - `insertText` is an optional `String` specifying the text to insert. `\n` is the platform-independent way to add
63
- a line break; line breaks should be added at the beginning of a line instead of at the end).
64
-
65
- The collection of helper functions shared by the built-in rules is available for use by custom rules in the [markdownlint-rule-helpers package](https://www.npmjs.com/package/markdownlint-rule-helpers).
66
-
67
- ## Examples
68
-
69
- - [Simple rules used by the project's test cases](../test/rules)
70
- - [Code for all `markdownlint` built-in rules](../lib)
71
- - [Package configuration for publishing to npm](../test/rules/npm)
72
- - Packages should export a single rule object or an `Array` of rule objects
73
- - [Custom rules from the Microsoft/vscode-docs-authoring repository](https://github.com/Microsoft/vscode-docs-authoring/tree/master/docs-markdown/markdownlint-custom-rules)
74
- - [Custom rules from the axibase/docs-util repository](https://github.com/axibase/docs-util/tree/master/linting-rules)
75
- - [Custom rules from the webhintio/hint repository](https://github.com/webhintio/hint/blob/master/scripts/lint-markdown.js)
76
-
77
- ## References
78
-
79
- - [CommonMark documentation and specification](https://commonmark.org/)
80
- - [`markdown-it` Markdown parser project page](https://github.com/markdown-it/markdown-it)
81
-
82
- ## Params
83
-
84
- The Markdown document:
85
-
86
- ```markdown
87
- # Title
88
-
89
- Text *text* text.
90
- ```
91
-
92
- Yields the `params` object:
93
-
94
- ```json
95
- {
96
- "name": "doc/example.md",
97
- "tokens": [
98
- {
99
- "type": "heading_open",
100
- "tag": "h1",
101
- "attrs": null,
102
- "map": [ 0, 1 ],
103
- "nesting": 1,
104
- "level": 0,
105
- "children": null,
106
- "content": "",
107
- "markup": "#",
108
- "info": "",
109
- "meta": null,
110
- "block": true,
111
- "hidden": false,
112
- "line": "# Title",
113
- "lineNumber": 1
114
- },
115
- {
116
- "type": "inline",
117
- "tag": "",
118
- "attrs": null,
119
- "map": [ 0, 1 ],
120
- "nesting": 0,
121
- "level": 1,
122
- "children": [
123
- {
124
- "type": "text",
125
- "tag": "",
126
- "attrs": null,
127
- "map": null,
128
- "nesting": 0,
129
- "level": 0,
130
- "children": null,
131
- "content": "Title",
132
- "markup": "",
133
- "info": "",
134
- "meta": null,
135
- "block": false,
136
- "hidden": false,
137
- "lineNumber": 1,
138
- "line": "# Title"
139
- }
140
- ],
141
- "content": "Title",
142
- "markup": "",
143
- "info": "",
144
- "meta": null,
145
- "block": true,
146
- "hidden": false,
147
- "line": "# Title",
148
- "lineNumber": 1
149
- },
150
- {
151
- "type": "heading_close",
152
- "tag": "h1",
153
- "attrs": null,
154
- "map": null,
155
- "nesting": -1,
156
- "level": 0,
157
- "children": null,
158
- "content": "",
159
- "markup": "#",
160
- "info": "",
161
- "meta": null,
162
- "block": true,
163
- "hidden": false
164
- },
165
- {
166
- "type": "paragraph_open",
167
- "tag": "p",
168
- "attrs": null,
169
- "map": [ 2, 3 ],
170
- "nesting": 1,
171
- "level": 0,
172
- "children": null,
173
- "content": "",
174
- "markup": "",
175
- "info": "",
176
- "meta": null,
177
- "block": true,
178
- "hidden": false,
179
- "line": "Text *text* text.",
180
- "lineNumber": 3
181
- },
182
- {
183
- "type": "inline",
184
- "tag": "",
185
- "attrs": null,
186
- "map": [ 2, 3 ],
187
- "nesting": 0,
188
- "level": 1,
189
- "children": [
190
- {
191
- "type": "text",
192
- "tag": "",
193
- "attrs": null,
194
- "map": null,
195
- "nesting": 0,
196
- "level": 0,
197
- "children": null,
198
- "content": "Text ",
199
- "markup": "",
200
- "info": "",
201
- "meta": null,
202
- "block": false,
203
- "hidden": false,
204
- "lineNumber": 3,
205
- "line": "Text *text* text."
206
- },
207
- {
208
- "type": "em_open",
209
- "tag": "em",
210
- "attrs": null,
211
- "map": null,
212
- "nesting": 1,
213
- "level": 1,
214
- "children": null,
215
- "content": "",
216
- "markup": "*",
217
- "info": "",
218
- "meta": null,
219
- "block": false,
220
- "hidden": false,
221
- "lineNumber": 3,
222
- "line": "Text *text* text."
223
- },
224
- {
225
- "type": "text",
226
- "tag": "",
227
- "attrs": null,
228
- "map": null,
229
- "nesting": 0,
230
- "level": 1,
231
- "children": null,
232
- "content": "text",
233
- "markup": "",
234
- "info": "",
235
- "meta": null,
236
- "block": false,
237
- "hidden": false,
238
- "lineNumber": 3,
239
- "line": "Text *text* text."
240
- },
241
- {
242
- "type": "em_close",
243
- "tag": "em",
244
- "attrs": null,
245
- "map": null,
246
- "nesting": -1,
247
- "level": 0,
248
- "children": null,
249
- "content": "",
250
- "markup": "*",
251
- "info": "",
252
- "meta": null,
253
- "block": false,
254
- "hidden": false,
255
- "lineNumber": 3,
256
- "line": "Text *text* text."
257
- },
258
- {
259
- "type": "text",
260
- "tag": "",
261
- "attrs": null,
262
- "map": null,
263
- "nesting": 0,
264
- "level": 0,
265
- "children": null,
266
- "content": " text.",
267
- "markup": "",
268
- "info": "",
269
- "meta": null,
270
- "block": false,
271
- "hidden": false,
272
- "lineNumber": 3,
273
- "line": "Text *text* text."
274
- }
275
- ],
276
- "content": "Text *text* text.",
277
- "markup": "",
278
- "info": "",
279
- "meta": null,
280
- "block": true,
281
- "hidden": false,
282
- "line": "Text *text* text.",
283
- "lineNumber": 3
284
- },
285
- {
286
- "type": "paragraph_close",
287
- "tag": "p",
288
- "attrs": null,
289
- "map": null,
290
- "nesting": -1,
291
- "level": 0,
292
- "children": null,
293
- "content": "",
294
- "markup": "",
295
- "info": "",
296
- "meta": null,
297
- "block": true,
298
- "hidden": false
299
- }
300
- ],
301
- "lines": [
302
- "# Title",
303
- "",
304
- "Text *text* text.",
305
- ""
306
- ],
307
- "frontMatterLines": [],
308
- "config": {
309
- "customValue1": "abc",
310
- "customValue2": 123
311
- }
312
- }
313
- ```
1
+ # Custom Rules
2
+
3
+ In addition to its built-in rules, `markdownlint` lets you enhance the linting experience by passing a list of custom rules using the [`options.customRules` property](../README.md#optionscustomrules).
4
+ Custom rules can do everything the built-in rules can and are defined inline or imported from another package ([keyword `markdownlint-rule` on npm](https://www.npmjs.com/search?q=keywords:markdownlint-rule)).
5
+ Custom rules can be disabled, enabled, and customized using the same syntax as built-in rules.
6
+
7
+ ## Authoring
8
+
9
+ Rules are defined by a name (or multiple names), a description, an optional link to more information, one or more tags, and a function that implements the rule's behavior.
10
+ That function is called once for each file/string input and is passed the parsed input and a function to log any violations.
11
+
12
+ A simple rule implementation looks like:
13
+
14
+ ```js
15
+ const { URL } = require("url");
16
+
17
+ module.exports = {
18
+ "names": [ "any-blockquote" ],
19
+ "description": "Rule that reports an error for any blockquote",
20
+ "information": new URL("https://example.com/rules/any-blockquote"),
21
+ "tags": [ "test" ],
22
+ "function": function rule(params, onError) {
23
+ params.tokens.filter(function filterToken(token) {
24
+ return token.type === "blockquote_open";
25
+ }).forEach(function forToken(blockquote) {
26
+ var lines = blockquote.map[1] - blockquote.map[0];
27
+ onError({
28
+ "lineNumber": blockquote.lineNumber,
29
+ "detail": "Blockquote spans " + lines + " line(s).",
30
+ "context": blockquote.line.substr(0, 7)
31
+ });
32
+ });
33
+ }
34
+ };
35
+ ```
36
+
37
+ A rule is implemented as an `Object` with one optional and four required properties:
38
+
39
+ - `names` is a required `Array` of `String` values that identify the rule in output messages and config.
40
+ - `description` is a required `String` value that describes the rule in output messages.
41
+ - `information` is an optional (absolute) `URL` of a link to more information about the rule.
42
+ - `tags` is a required `Array` of `String` values that groups related rules for easier customization.
43
+ - `function` is a required synchronous `Function` that implements the rule and is passed two parameters:
44
+ - `params` is an `Object` with properties that describe the content being analyzed:
45
+ - `name` is a `String` that identifies the input file/string.
46
+ - `tokens` is an `Array` of [`markdown-it` `Token` objects](https://markdown-it.github.io/markdown-it/#Token)
47
+ with added `line` and `lineNumber` properties.
48
+ - `lines` is an `Array` of `String` values corresponding to the lines of the input file/string.
49
+ - `frontMatterLines` is an `Array` of `String` values corresponding to any front matter (not present in `lines`).
50
+ - `config` is an `Object` corresponding to the rule's entry in `options.config` (if present).
51
+ - `onError` is a function that takes a single `Object` parameter with one required and four optional properties:
52
+ - `lineNumber` is a required `Number` specifying the 1-based line number of the error.
53
+ - `details` is an optional `String` with information about what caused the error.
54
+ - `context` is an optional `String` with relevant text surrounding the error location.
55
+ - `range` is an optional `Array` with two `Number` values identifying the 1-based column and length of the error.
56
+ - `fixInfo` is an optional `Object` with information about how to fix the error (all properties are optional, but
57
+ at least one of `deleteCount` and `insertText` should be present; when applying a fix, the delete should be
58
+ performed before the insert):
59
+ - `lineNumber` is an optional `Number` specifying the 1-based line number of the edit.
60
+ - `editColumn` is an optional `Number` specifying the 1-based column number of the edit.
61
+ - `deleteCount` is an optional `Number` specifying the count of characters to delete.
62
+ - `insertText` is an optional `String` specifying the text to insert. `\n` is the platform-independent way to add
63
+ a line break; line breaks should be added at the beginning of a line instead of at the end).
64
+
65
+ The collection of helper functions shared by the built-in rules is available for use by custom rules in the [markdownlint-rule-helpers package](https://www.npmjs.com/package/markdownlint-rule-helpers).
66
+
67
+ ## Examples
68
+
69
+ - [Simple rules used by the project's test cases](../test/rules)
70
+ - [Code for all `markdownlint` built-in rules](../lib)
71
+ - [Package configuration for publishing to npm](../test/rules/npm)
72
+ - Packages should export a single rule object or an `Array` of rule objects
73
+ - [Custom rules from the Microsoft/vscode-docs-authoring repository](https://github.com/Microsoft/vscode-docs-authoring/tree/master/docs-markdown/markdownlint-custom-rules)
74
+ - [Custom rules from the axibase/docs-util repository](https://github.com/axibase/docs-util/tree/master/linting-rules)
75
+ - [Custom rules from the webhintio/hint repository](https://github.com/webhintio/hint/blob/master/scripts/lint-markdown.js)
76
+
77
+ ## References
78
+
79
+ - [CommonMark documentation and specification](https://commonmark.org/)
80
+ - [`markdown-it` Markdown parser project page](https://github.com/markdown-it/markdown-it)
81
+
82
+ ## Params
83
+
84
+ The Markdown document:
85
+
86
+ ```markdown
87
+ # Title
88
+
89
+ Text *text* text.
90
+ ```
91
+
92
+ Yields the `params` object:
93
+
94
+ ```json
95
+ {
96
+ "name": "doc/example.md",
97
+ "tokens": [
98
+ {
99
+ "type": "heading_open",
100
+ "tag": "h1",
101
+ "attrs": null,
102
+ "map": [ 0, 1 ],
103
+ "nesting": 1,
104
+ "level": 0,
105
+ "children": null,
106
+ "content": "",
107
+ "markup": "#",
108
+ "info": "",
109
+ "meta": null,
110
+ "block": true,
111
+ "hidden": false,
112
+ "line": "# Title",
113
+ "lineNumber": 1
114
+ },
115
+ {
116
+ "type": "inline",
117
+ "tag": "",
118
+ "attrs": null,
119
+ "map": [ 0, 1 ],
120
+ "nesting": 0,
121
+ "level": 1,
122
+ "children": [
123
+ {
124
+ "type": "text",
125
+ "tag": "",
126
+ "attrs": null,
127
+ "map": null,
128
+ "nesting": 0,
129
+ "level": 0,
130
+ "children": null,
131
+ "content": "Title",
132
+ "markup": "",
133
+ "info": "",
134
+ "meta": null,
135
+ "block": false,
136
+ "hidden": false,
137
+ "lineNumber": 1,
138
+ "line": "# Title"
139
+ }
140
+ ],
141
+ "content": "Title",
142
+ "markup": "",
143
+ "info": "",
144
+ "meta": null,
145
+ "block": true,
146
+ "hidden": false,
147
+ "line": "# Title",
148
+ "lineNumber": 1
149
+ },
150
+ {
151
+ "type": "heading_close",
152
+ "tag": "h1",
153
+ "attrs": null,
154
+ "map": null,
155
+ "nesting": -1,
156
+ "level": 0,
157
+ "children": null,
158
+ "content": "",
159
+ "markup": "#",
160
+ "info": "",
161
+ "meta": null,
162
+ "block": true,
163
+ "hidden": false
164
+ },
165
+ {
166
+ "type": "paragraph_open",
167
+ "tag": "p",
168
+ "attrs": null,
169
+ "map": [ 2, 3 ],
170
+ "nesting": 1,
171
+ "level": 0,
172
+ "children": null,
173
+ "content": "",
174
+ "markup": "",
175
+ "info": "",
176
+ "meta": null,
177
+ "block": true,
178
+ "hidden": false,
179
+ "line": "Text *text* text.",
180
+ "lineNumber": 3
181
+ },
182
+ {
183
+ "type": "inline",
184
+ "tag": "",
185
+ "attrs": null,
186
+ "map": [ 2, 3 ],
187
+ "nesting": 0,
188
+ "level": 1,
189
+ "children": [
190
+ {
191
+ "type": "text",
192
+ "tag": "",
193
+ "attrs": null,
194
+ "map": null,
195
+ "nesting": 0,
196
+ "level": 0,
197
+ "children": null,
198
+ "content": "Text ",
199
+ "markup": "",
200
+ "info": "",
201
+ "meta": null,
202
+ "block": false,
203
+ "hidden": false,
204
+ "lineNumber": 3,
205
+ "line": "Text *text* text."
206
+ },
207
+ {
208
+ "type": "em_open",
209
+ "tag": "em",
210
+ "attrs": null,
211
+ "map": null,
212
+ "nesting": 1,
213
+ "level": 1,
214
+ "children": null,
215
+ "content": "",
216
+ "markup": "*",
217
+ "info": "",
218
+ "meta": null,
219
+ "block": false,
220
+ "hidden": false,
221
+ "lineNumber": 3,
222
+ "line": "Text *text* text."
223
+ },
224
+ {
225
+ "type": "text",
226
+ "tag": "",
227
+ "attrs": null,
228
+ "map": null,
229
+ "nesting": 0,
230
+ "level": 1,
231
+ "children": null,
232
+ "content": "text",
233
+ "markup": "",
234
+ "info": "",
235
+ "meta": null,
236
+ "block": false,
237
+ "hidden": false,
238
+ "lineNumber": 3,
239
+ "line": "Text *text* text."
240
+ },
241
+ {
242
+ "type": "em_close",
243
+ "tag": "em",
244
+ "attrs": null,
245
+ "map": null,
246
+ "nesting": -1,
247
+ "level": 0,
248
+ "children": null,
249
+ "content": "",
250
+ "markup": "*",
251
+ "info": "",
252
+ "meta": null,
253
+ "block": false,
254
+ "hidden": false,
255
+ "lineNumber": 3,
256
+ "line": "Text *text* text."
257
+ },
258
+ {
259
+ "type": "text",
260
+ "tag": "",
261
+ "attrs": null,
262
+ "map": null,
263
+ "nesting": 0,
264
+ "level": 0,
265
+ "children": null,
266
+ "content": " text.",
267
+ "markup": "",
268
+ "info": "",
269
+ "meta": null,
270
+ "block": false,
271
+ "hidden": false,
272
+ "lineNumber": 3,
273
+ "line": "Text *text* text."
274
+ }
275
+ ],
276
+ "content": "Text *text* text.",
277
+ "markup": "",
278
+ "info": "",
279
+ "meta": null,
280
+ "block": true,
281
+ "hidden": false,
282
+ "line": "Text *text* text.",
283
+ "lineNumber": 3
284
+ },
285
+ {
286
+ "type": "paragraph_close",
287
+ "tag": "p",
288
+ "attrs": null,
289
+ "map": null,
290
+ "nesting": -1,
291
+ "level": 0,
292
+ "children": null,
293
+ "content": "",
294
+ "markup": "",
295
+ "info": "",
296
+ "meta": null,
297
+ "block": true,
298
+ "hidden": false
299
+ }
300
+ ],
301
+ "lines": [
302
+ "# Title",
303
+ "",
304
+ "Text *text* text.",
305
+ ""
306
+ ],
307
+ "frontMatterLines": [],
308
+ "config": {
309
+ "customValue1": "abc",
310
+ "customValue2": 123
311
+ }
312
+ }
313
+ ```