markdownlint 0.21.1 → 0.24.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 +1 -0
- package/LICENSE +1 -1
- package/README.md +140 -80
- package/demo/markdownlint-browser.js +1209 -1701
- package/doc/Prettier.md +23 -0
- package/doc/Rules.md +121 -76
- package/helpers/LICENSE +1 -1
- package/helpers/helpers.js +126 -37
- package/helpers/package.json +1 -1
- package/lib/cache.js +18 -9
- package/lib/markdownlint.d.ts +28 -12
- package/lib/markdownlint.js +185 -62
- package/lib/md002.js +1 -1
- package/lib/md004.js +46 -13
- package/lib/md006.js +1 -1
- package/lib/md009.js +25 -23
- package/lib/md010.js +5 -1
- 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/md026.js +7 -4
- package/lib/md028.js +1 -9
- package/lib/md032.js +2 -2
- package/lib/md037.js +35 -9
- package/lib/md039.js +2 -2
- package/lib/md041.js +14 -3
- package/lib/md043.js +27 -11
- package/lib/md044.js +54 -71
- package/lib/rules.js +2 -1
- package/package.json +39 -32
- package/schema/.markdownlint.jsonc +252 -0
- package/schema/.markdownlint.yaml +227 -0
- package/schema/markdownlint-config-schema.json +36 -23
- package/schema/build-config-schema.js +0 -409
package/CONTRIBUTING.md
CHANGED
|
@@ -43,6 +43,7 @@ Open pull requests against the `next` branch.
|
|
|
43
43
|
That's where the latest changes are staged for the next release.
|
|
44
44
|
Include the text "(fixes #??)" at the end of the commit message so the pull request will be associated with the relevant issue.
|
|
45
45
|
End commit messages with a period (`.`).
|
|
46
|
+
Do not include `package-lock.json` in the pull request.
|
|
46
47
|
Once accepted, the tag `fixed in next` will be added to the issue.
|
|
47
48
|
When the commit is merged to the main branch during the release process, the issue will be closed automatically.
|
|
48
49
|
(See [Closing issues using keywords](https://help.github.com/articles/closing-issues-using-keywords/) for details.)
|
package/LICENSE
CHANGED
package/README.md
CHANGED
|
@@ -3,7 +3,6 @@
|
|
|
3
3
|
> A Node.js style checker and lint tool for Markdown/CommonMark files.
|
|
4
4
|
|
|
5
5
|
[![npm version][npm-image]][npm-url]
|
|
6
|
-
[![CI Status][ci-image]][ci-url]
|
|
7
6
|
[![License][license-image]][license-url]
|
|
8
7
|
|
|
9
8
|
## Install
|
|
@@ -14,12 +13,13 @@ npm install markdownlint --save-dev
|
|
|
14
13
|
|
|
15
14
|
## Overview
|
|
16
15
|
|
|
17
|
-
The [Markdown](https://en.wikipedia.org/wiki/Markdown) markup language
|
|
18
|
-
designed to be easy to read, write, and understand. It succeeds -
|
|
19
|
-
flexibility is both a benefit and a drawback. Many styles are
|
|
20
|
-
formatting can be inconsistent. Some constructs don't
|
|
21
|
-
parsers and should be avoided. The
|
|
22
|
-
specification standardizes
|
|
16
|
+
The [Markdown](https://en.wikipedia.org/wiki/Markdown) markup language
|
|
17
|
+
is designed to be easy to read, write, and understand. It succeeds -
|
|
18
|
+
and its flexibility is both a benefit and a drawback. Many styles are
|
|
19
|
+
possible, so formatting can be inconsistent. Some constructs don't
|
|
20
|
+
work well in all parsers and should be avoided. The
|
|
21
|
+
[CommonMark](https://commonmark.org/) specification standardizes
|
|
22
|
+
parsers - but not authors.
|
|
23
23
|
|
|
24
24
|
`markdownlint` is a
|
|
25
25
|
[static analysis](https://en.wikipedia.org/wiki/Static_program_analysis)
|
|
@@ -39,7 +39,7 @@ and test cases came directly from that project.
|
|
|
39
39
|
* [GitHub Super-Linter Action](https://github.com/github/super-linter)
|
|
40
40
|
* [GitHub Actions problem matcher for markdownlint-cli](https://github.com/xt0rted/markdownlint-problem-matcher)
|
|
41
41
|
* Editor
|
|
42
|
-
* [vscode-markdownlint extension for VS Code](https://marketplace.visualstudio.com/items
|
|
42
|
+
* [vscode-markdownlint extension for VS Code](https://marketplace.visualstudio.com/items?itemName=DavidAnson.vscode-markdownlint)
|
|
43
43
|
* [Sublime Text markdownlint for Sublime Text](https://packagecontrol.io/packages/SublimeLinter-contrib-markdownlint)
|
|
44
44
|
* [linter-node-markdownlint extension for Atom](https://atom.io/packages/linter-node-markdownlint)
|
|
45
45
|
* [coc-markdownlint extension for Vim/Neovim](https://github.com/fannheyward/coc-markdownlint)
|
|
@@ -56,8 +56,10 @@ playground for learning and exploring.
|
|
|
56
56
|
|
|
57
57
|
## Rules / Aliases
|
|
58
58
|
|
|
59
|
+
<!-- markdownlint-disable line-length -->
|
|
60
|
+
|
|
59
61
|
* **[MD001](doc/Rules.md#md001)** *heading-increment/header-increment* - Heading levels should only increment by one level at a time
|
|
60
|
-
* ~~**[MD002](doc/Rules.md#md002)** *first-heading-h1/first-header-h1* - First heading should be a top
|
|
62
|
+
* ~~**[MD002](doc/Rules.md#md002)** *first-heading-h1/first-header-h1* - First heading should be a top-level heading~~
|
|
61
63
|
* **[MD003](doc/Rules.md#md003)** *heading-style/header-style* - Heading style
|
|
62
64
|
* **[MD004](doc/Rules.md#md004)** *ul-style* - Unordered list style
|
|
63
65
|
* **[MD005](doc/Rules.md#md005)** *list-indent* - Inconsistent indentation for list items at the same level
|
|
@@ -76,7 +78,7 @@ playground for learning and exploring.
|
|
|
76
78
|
* **[MD022](doc/Rules.md#md022)** *blanks-around-headings/blanks-around-headers* - Headings should be surrounded by blank lines
|
|
77
79
|
* **[MD023](doc/Rules.md#md023)** *heading-start-left/header-start-left* - Headings must start at the beginning of the line
|
|
78
80
|
* **[MD024](doc/Rules.md#md024)** *no-duplicate-heading/no-duplicate-header* - Multiple headings with the same content
|
|
79
|
-
* **[MD025](doc/Rules.md#md025)** *single-title/single-h1* - Multiple top
|
|
81
|
+
* **[MD025](doc/Rules.md#md025)** *single-title/single-h1* - Multiple top-level headings in the same document
|
|
80
82
|
* **[MD026](doc/Rules.md#md026)** *no-trailing-punctuation* - Trailing punctuation in heading
|
|
81
83
|
* **[MD027](doc/Rules.md#md027)** *no-multiple-space-blockquote* - Multiple spaces after blockquote symbol
|
|
82
84
|
* **[MD028](doc/Rules.md#md028)** *no-blanks-blockquote* - Blank line inside blockquote
|
|
@@ -92,7 +94,7 @@ playground for learning and exploring.
|
|
|
92
94
|
* **[MD038](doc/Rules.md#md038)** *no-space-in-code* - Spaces inside code span elements
|
|
93
95
|
* **[MD039](doc/Rules.md#md039)** *no-space-in-links* - Spaces inside link text
|
|
94
96
|
* **[MD040](doc/Rules.md#md040)** *fenced-code-language* - Fenced code blocks should have a language specified
|
|
95
|
-
* **[MD041](doc/Rules.md#md041)** *first-line-heading/first-line-h1* - First line in file should be a top
|
|
97
|
+
* **[MD041](doc/Rules.md#md041)** *first-line-heading/first-line-h1* - First line in a file should be a top-level heading
|
|
96
98
|
* **[MD042](doc/Rules.md#md042)** *no-empty-links* - No empty links
|
|
97
99
|
* **[MD043](doc/Rules.md#md043)** *required-headings/required-headers* - Required heading structure
|
|
98
100
|
* **[MD044](doc/Rules.md#md044)** *proper-names* - Proper names should have the correct capitalization
|
|
@@ -101,17 +103,20 @@ playground for learning and exploring.
|
|
|
101
103
|
* **[MD047](doc/Rules.md#md047)** *single-trailing-newline* - Files should end with a single newline character
|
|
102
104
|
* **[MD048](doc/Rules.md#md048)** *code-fence-style* - Code fence style
|
|
103
105
|
|
|
106
|
+
<!-- markdownlint-restore -->
|
|
107
|
+
|
|
104
108
|
See [Rules.md](doc/Rules.md) for more details.
|
|
105
109
|
|
|
106
110
|
~~Struck through~~ rules are deprecated, and provided for backward-compatibility.
|
|
107
111
|
|
|
108
|
-
> All rules with `heading` as part of their name are also available as
|
|
109
|
-
> aliases (e.g. `heading-increment` is also available as `header-increment`).
|
|
112
|
+
> All rules with `heading` as part of their name are also available as
|
|
113
|
+
> `header` aliases (e.g. `heading-increment` is also available as `header-increment`).
|
|
110
114
|
> The use of `header` is deprecated and provided for backward-compatibility.
|
|
111
115
|
|
|
112
116
|
## Tags
|
|
113
117
|
|
|
114
|
-
Tags group related rules and can be used to enable/disable multiple
|
|
118
|
+
Tags group related rules and can be used to enable/disable multiple
|
|
119
|
+
rules at once.
|
|
115
120
|
|
|
116
121
|
* **accessibility** - MD045
|
|
117
122
|
* **atx** - MD018, MD019
|
|
@@ -122,10 +127,10 @@ Tags group related rules and can be used to enable/disable multiple rules at onc
|
|
|
122
127
|
* **code** - MD014, MD031, MD038, MD040, MD046, MD048
|
|
123
128
|
* **emphasis** - MD036, MD037
|
|
124
129
|
* **hard_tab** - MD010
|
|
125
|
-
* **headers** - MD001, MD002, MD003, MD018, MD019, MD020, MD021, MD022,
|
|
126
|
-
MD024, MD025, MD026, MD036, MD041, MD043
|
|
127
|
-
* **headings** - MD001, MD002, MD003, MD018, MD019, MD020, MD021, MD022,
|
|
128
|
-
MD024, MD025, MD026, MD036, MD041, MD043
|
|
130
|
+
* **headers** - MD001, MD002, MD003, MD018, MD019, MD020, MD021, MD022,
|
|
131
|
+
MD023, MD024, MD025, MD026, MD036, MD041, MD043
|
|
132
|
+
* **headings** - MD001, MD002, MD003, MD018, MD019, MD020, MD021, MD022,
|
|
133
|
+
MD023, MD024, MD025, MD026, MD036, MD041, MD043
|
|
129
134
|
* **hr** - MD035
|
|
130
135
|
* **html** - MD033
|
|
131
136
|
* **images** - MD045
|
|
@@ -138,30 +143,42 @@ Tags group related rules and can be used to enable/disable multiple rules at onc
|
|
|
138
143
|
* **spelling** - MD044
|
|
139
144
|
* **ul** - MD004, MD005, MD006, MD007, MD030, MD032
|
|
140
145
|
* **url** - MD034
|
|
141
|
-
* **whitespace** - MD009, MD010, MD012, MD027, MD028, MD030, MD037,
|
|
146
|
+
* **whitespace** - MD009, MD010, MD012, MD027, MD028, MD030, MD037,
|
|
147
|
+
MD038, MD039
|
|
142
148
|
|
|
143
149
|
## Configuration
|
|
144
150
|
|
|
145
|
-
Text passed to `markdownlint` is parsed as Markdown, analyzed, and any
|
|
146
|
-
Two kinds of text are ignored:
|
|
151
|
+
Text passed to `markdownlint` is parsed as Markdown, analyzed, and any
|
|
152
|
+
issues reported. Two kinds of text are ignored:
|
|
147
153
|
|
|
148
154
|
* [HTML comments](https://www.w3.org/TR/html5/syntax.html#comments)
|
|
149
|
-
* [Front matter](https://jekyllrb.com/docs/frontmatter/) (see
|
|
155
|
+
* [Front matter](https://jekyllrb.com/docs/frontmatter/) (see
|
|
156
|
+
`options.frontMatter` below)
|
|
150
157
|
|
|
151
|
-
Rules can be enabled, disabled, and configured via `options.config`
|
|
152
|
-
below) to define the expected behavior for a set of inputs.
|
|
153
|
-
rules at a particular location within a file, add
|
|
154
|
-
appropriate place (HTML comments don't
|
|
158
|
+
Rules can be enabled, disabled, and configured via `options.config`
|
|
159
|
+
(described below) to define the expected behavior for a set of inputs.
|
|
160
|
+
To enable or disable rules at a particular location within a file, add
|
|
161
|
+
one of these markers to the appropriate place (HTML comments don't
|
|
162
|
+
appear in the final markup):
|
|
155
163
|
|
|
156
164
|
* Disable all rules: `<!-- markdownlint-disable -->`
|
|
157
165
|
* Enable all rules: `<!-- markdownlint-enable -->`
|
|
166
|
+
* Disable all rules for the next line only: `<!-- markdownlint-disable-next-line -->`
|
|
158
167
|
* Disable one or more rules by name: `<!-- markdownlint-disable MD001 MD005 -->`
|
|
159
168
|
* Enable one or more rules by name: `<!-- markdownlint-enable MD001 MD005 -->`
|
|
169
|
+
* Disable one or more rules by name for the next line only: `<!-- markdownlint-disable-next-line MD001 MD005 -->`
|
|
160
170
|
* Capture the current rule configuration: `<!-- markdownlint-capture -->`
|
|
161
171
|
* Restore the captured rule configuration: `<!-- markdownlint-restore -->`
|
|
162
172
|
|
|
163
173
|
For example:
|
|
164
174
|
|
|
175
|
+
```markdown
|
|
176
|
+
<!-- markdownlint-disable-next-line no-space-in-emphasis -->
|
|
177
|
+
deliberate space * in * emphasis
|
|
178
|
+
```
|
|
179
|
+
|
|
180
|
+
Or:
|
|
181
|
+
|
|
165
182
|
```markdown
|
|
166
183
|
<!-- markdownlint-disable no-space-in-emphasis -->
|
|
167
184
|
deliberate space * in * emphasis
|
|
@@ -177,9 +194,9 @@ any violations you want
|
|
|
177
194
|
<!-- markdownlint-restore -->
|
|
178
195
|
```
|
|
179
196
|
|
|
180
|
-
The initial configuration is captured by default (as if every document
|
|
181
|
-
with `<!-- markdownlint-capture -->`), so the pattern above can
|
|
182
|
-
more simply:
|
|
197
|
+
The initial configuration is captured by default (as if every document
|
|
198
|
+
began with `<!-- markdownlint-capture -->`), so the pattern above can
|
|
199
|
+
be expressed more simply:
|
|
183
200
|
|
|
184
201
|
```markdown
|
|
185
202
|
<!-- markdownlint-disable -->
|
|
@@ -204,8 +221,8 @@ the following syntax is supported:
|
|
|
204
221
|
|
|
205
222
|
This can be used to "hide" `markdownlint` comments at the bottom of a file.
|
|
206
223
|
|
|
207
|
-
In cases where it is desirable to change the configuration of one or
|
|
208
|
-
for a file, the following more advanced syntax is supported:
|
|
224
|
+
In cases where it is desirable to change the configuration of one or
|
|
225
|
+
more rules for a file, the following more advanced syntax is supported:
|
|
209
226
|
|
|
210
227
|
* Configure: `<!-- markdownlint-configure-file { options.config JSON } -->`
|
|
211
228
|
|
|
@@ -228,8 +245,8 @@ or
|
|
|
228
245
|
-->
|
|
229
246
|
```
|
|
230
247
|
|
|
231
|
-
These changes apply to the entire file regardless of where the comment
|
|
232
|
-
located. Multiple such comments (if present) are applied top-to-bottom.
|
|
248
|
+
These changes apply to the entire file regardless of where the comment
|
|
249
|
+
is located. Multiple such comments (if present) are applied top-to-bottom.
|
|
233
250
|
|
|
234
251
|
## API
|
|
235
252
|
|
|
@@ -277,7 +294,8 @@ function markdownlint(options) { ... }
|
|
|
277
294
|
|
|
278
295
|
Type: `Object`
|
|
279
296
|
|
|
280
|
-
Configures the function.
|
|
297
|
+
Configures the function. All properties are optional, but at least one
|
|
298
|
+
of `files` or `strings` should be set to provide input.
|
|
281
299
|
|
|
282
300
|
##### options.customRules
|
|
283
301
|
|
|
@@ -285,8 +303,9 @@ Type: `Array` of `Object`
|
|
|
285
303
|
|
|
286
304
|
List of custom rules to include with the default rule set for linting.
|
|
287
305
|
|
|
288
|
-
Each array element should define a rule. Rules are typically exported
|
|
289
|
-
package, but can be defined locally. Custom rules are
|
|
306
|
+
Each array element should define a rule. Rules are typically exported
|
|
307
|
+
by another package, but can be defined locally. Custom rules are
|
|
308
|
+
identified by the
|
|
290
309
|
[keyword `markdownlint-rule` on npm](https://www.npmjs.com/search?q=keywords:markdownlint-rule).
|
|
291
310
|
|
|
292
311
|
Example:
|
|
@@ -298,7 +317,8 @@ const options = {
|
|
|
298
317
|
};
|
|
299
318
|
```
|
|
300
319
|
|
|
301
|
-
See [CustomRules.md](doc/CustomRules.md) for details about authoring
|
|
320
|
+
See [CustomRules.md](doc/CustomRules.md) for details about authoring
|
|
321
|
+
custom rules.
|
|
302
322
|
|
|
303
323
|
##### options.files
|
|
304
324
|
|
|
@@ -307,8 +327,8 @@ Type: `Array` of `String`
|
|
|
307
327
|
List of files to lint.
|
|
308
328
|
|
|
309
329
|
Each array element should be a single file (via relative or absolute path);
|
|
310
|
-
[globbing](https://en.wikipedia.org/wiki/Glob_%28programming%29) is the
|
|
311
|
-
responsibility.
|
|
330
|
+
[globbing](https://en.wikipedia.org/wiki/Glob_%28programming%29) is the
|
|
331
|
+
caller's responsibility.
|
|
312
332
|
|
|
313
333
|
Example: `[ "one.md", "dir/two.md" ]`
|
|
314
334
|
|
|
@@ -318,9 +338,9 @@ Type: `Object` mapping `String` to `String`
|
|
|
318
338
|
|
|
319
339
|
Map of identifiers to strings for linting.
|
|
320
340
|
|
|
321
|
-
When Markdown content is not available as files, it can be passed as
|
|
322
|
-
The keys of the `strings` object are used to identify each
|
|
323
|
-
`result` summary.
|
|
341
|
+
When Markdown content is not available as files, it can be passed as
|
|
342
|
+
strings. The keys of the `strings` object are used to identify each
|
|
343
|
+
input value in the `result` summary.
|
|
324
344
|
|
|
325
345
|
Example:
|
|
326
346
|
|
|
@@ -340,12 +360,13 @@ Configures the rules to use.
|
|
|
340
360
|
Object keys are rule names or aliases and values are the rule's configuration.
|
|
341
361
|
The value `false` disables a rule, `true` enables its default configuration,
|
|
342
362
|
and passing an object customizes its settings. Setting the special `default`
|
|
343
|
-
rule to `true` or `false` includes/excludes all rules by default. Enabling
|
|
344
|
-
disabling a tag name (ex: `whitespace`) affects all rules having that
|
|
363
|
+
rule to `true` or `false` includes/excludes all rules by default. Enabling
|
|
364
|
+
or disabling a tag name (ex: `whitespace`) affects all rules having that
|
|
365
|
+
tag.
|
|
345
366
|
|
|
346
|
-
The `default` rule is applied first, then keys are processed in order
|
|
347
|
-
to bottom with later values overriding earlier ones. Keys
|
|
348
|
-
aliases, tags, and `default`) are not case-sensitive.
|
|
367
|
+
The `default` rule is applied first, then keys are processed in order
|
|
368
|
+
from top to bottom with later values overriding earlier ones. Keys
|
|
369
|
+
(including rule names, aliases, tags, and `default`) are not case-sensitive.
|
|
349
370
|
|
|
350
371
|
Example:
|
|
351
372
|
|
|
@@ -359,8 +380,12 @@ Example:
|
|
|
359
380
|
}
|
|
360
381
|
```
|
|
361
382
|
|
|
362
|
-
|
|
363
|
-
[
|
|
383
|
+
See [.markdownlint.jsonc](schema/.markdownlint.jsonc) and/or
|
|
384
|
+
[.markdownlint.yaml](schema/.markdownlint.yaml) for an example
|
|
385
|
+
configuration object with all properties set to the default value.
|
|
386
|
+
|
|
387
|
+
Sets of rules (known as a "style") can be stored separately and loaded
|
|
388
|
+
as [JSON](https://en.wikipedia.org/wiki/JSON).
|
|
364
389
|
|
|
365
390
|
Example:
|
|
366
391
|
|
|
@@ -374,10 +399,12 @@ const options = {
|
|
|
374
399
|
See the [style](style) directory for more samples.
|
|
375
400
|
|
|
376
401
|
See [markdownlint-config-schema.json](schema/markdownlint-config-schema.json)
|
|
377
|
-
for the [JSON Schema](https://json-schema.org/) of the `options.config`
|
|
402
|
+
for the [JSON Schema](https://json-schema.org/) of the `options.config`
|
|
403
|
+
object.
|
|
378
404
|
|
|
379
|
-
For more advanced scenarios, styles can reference and extend other styles.
|
|
380
|
-
`readConfig` and `readConfigSync` functions can be used to read such
|
|
405
|
+
For more advanced scenarios, styles can reference and extend other styles.
|
|
406
|
+
The `readConfig` and `readConfigSync` functions can be used to read such
|
|
407
|
+
styles.
|
|
381
408
|
|
|
382
409
|
For example, assuming a `base.json` configuration file:
|
|
383
410
|
|
|
@@ -419,21 +446,22 @@ const options = {
|
|
|
419
446
|
|
|
420
447
|
Type: `RegExp`
|
|
421
448
|
|
|
422
|
-
Matches any [front matter](https://jekyllrb.com/docs/frontmatter/)
|
|
423
|
-
beginning of a file.
|
|
449
|
+
Matches any [front matter](https://jekyllrb.com/docs/frontmatter/)
|
|
450
|
+
found at the beginning of a file.
|
|
424
451
|
|
|
425
|
-
Some Markdown content begins with metadata; the default `RegExp` for
|
|
426
|
-
ignores common forms of "front matter". To match differently,
|
|
427
|
-
`RegExp` or use the value `null` to disable the feature.
|
|
452
|
+
Some Markdown content begins with metadata; the default `RegExp` for
|
|
453
|
+
this option ignores common forms of "front matter". To match differently,
|
|
454
|
+
specify a custom `RegExp` or use the value `null` to disable the feature.
|
|
428
455
|
|
|
429
456
|
The default value:
|
|
430
457
|
|
|
431
458
|
```js
|
|
432
|
-
/((^---\s*$[^]*?^---\s*$)|(^\+\+\+\s*$[^]*?^(\+\+\+|\.\.\.)\s*$))(\r\n|\r|\n|$)/m
|
|
459
|
+
/((^---\s*$[^]*?^---\s*$)|(^\+\+\+\s*$[^]*?^(\+\+\+|\.\.\.)\s*$)|(^\{\s*$[^]*?^\}\s*$))(\r\n|\r|\n|$)/m
|
|
433
460
|
```
|
|
434
461
|
|
|
435
|
-
Ignores [YAML](https://en.wikipedia.org/wiki/YAML)
|
|
436
|
-
[TOML](https://en.wikipedia.org/wiki/TOML)
|
|
462
|
+
Ignores [YAML](https://en.wikipedia.org/wiki/YAML),
|
|
463
|
+
[TOML](https://en.wikipedia.org/wiki/TOML), and
|
|
464
|
+
[JSON](https://en.wikipedia.org/wiki/JSON) front matter such as:
|
|
437
465
|
|
|
438
466
|
```text
|
|
439
467
|
---
|
|
@@ -448,16 +476,16 @@ Note: Matches must occur at the start of the file.
|
|
|
448
476
|
|
|
449
477
|
Type: `Boolean`
|
|
450
478
|
|
|
451
|
-
Catches exceptions thrown during rule processing and reports the problem
|
|
452
|
-
rule violation.
|
|
479
|
+
Catches exceptions thrown during rule processing and reports the problem
|
|
480
|
+
as a rule violation.
|
|
453
481
|
|
|
454
482
|
By default, exceptions thrown by rules (or the library itself) are unhandled
|
|
455
483
|
and bubble up the stack to the caller in the conventional manner. By setting
|
|
456
|
-
`handleRuleFailures` to `true`, exceptions thrown by failing rules will
|
|
457
|
-
handled by the library and the exception message logged as a rule violation.
|
|
484
|
+
`handleRuleFailures` to `true`, exceptions thrown by failing rules will
|
|
485
|
+
be handled by the library and the exception message logged as a rule violation.
|
|
458
486
|
This setting can be useful in the presence of (custom) rules that encounter
|
|
459
|
-
unexpected syntax and fail. By enabling this option, the linting process
|
|
460
|
-
allowed to continue and report any violations that were found.
|
|
487
|
+
unexpected syntax and fail. By enabling this option, the linting process
|
|
488
|
+
is allowed to continue and report any violations that were found.
|
|
461
489
|
|
|
462
490
|
##### options.noInlineConfig
|
|
463
491
|
|
|
@@ -507,6 +535,16 @@ Each item in the top-level `Array` should be of the form:
|
|
|
507
535
|
[ require("markdown-it-plugin"), plugin_param_0, plugin_param_1, ... ]
|
|
508
536
|
```
|
|
509
537
|
|
|
538
|
+
##### options.fs
|
|
539
|
+
|
|
540
|
+
Type: `Object` implementing the [file system API](https://nodejs.org/api/fs.html)
|
|
541
|
+
|
|
542
|
+
In advanced scenarios, it may be desirable to bypass the default file system API.
|
|
543
|
+
If a custom file system implementation is provided, `markdownlint` will use that
|
|
544
|
+
instead of invoking `require("fs")`.
|
|
545
|
+
|
|
546
|
+
Note: The only methods called are `readFile` and `readFileSync`.
|
|
547
|
+
|
|
510
548
|
#### callback
|
|
511
549
|
|
|
512
550
|
Type: `Function` taking (`Error`, `Object`)
|
|
@@ -539,10 +577,11 @@ Asynchronous API:
|
|
|
539
577
|
*
|
|
540
578
|
* @param {string} file Configuration file name.
|
|
541
579
|
* @param {ConfigurationParser[] | ReadConfigCallback} parsers Parsing function(s).
|
|
580
|
+
* @param {Object} [fs] File system implementation.
|
|
542
581
|
* @param {ReadConfigCallback} [callback] Callback (err, result) function.
|
|
543
582
|
* @returns {void}
|
|
544
583
|
*/
|
|
545
|
-
function readConfig(file, parsers, callback) { ... }
|
|
584
|
+
function readConfig(file, parsers, fs, callback) { ... }
|
|
546
585
|
```
|
|
547
586
|
|
|
548
587
|
Synchronous API:
|
|
@@ -553,13 +592,14 @@ Synchronous API:
|
|
|
553
592
|
*
|
|
554
593
|
* @param {string} file Configuration file name.
|
|
555
594
|
* @param {ConfigurationParser[]} [parsers] Parsing function(s).
|
|
595
|
+
* @param {Object} [fs] File system implementation.
|
|
556
596
|
* @returns {Configuration} Configuration object.
|
|
557
597
|
*/
|
|
558
|
-
function readConfigSync(file, parsers) { ... }
|
|
598
|
+
function readConfigSync(file, parsers, fs) { ... }
|
|
559
599
|
```
|
|
560
600
|
|
|
561
601
|
Promise API (in the `promises` namespace like Node.js's
|
|
562
|
-
[`fs` Promises API](https://nodejs.org/api/fs.html#
|
|
602
|
+
[`fs` Promises API](https://nodejs.org/api/fs.html#fs_promises_api)):
|
|
563
603
|
|
|
564
604
|
```js
|
|
565
605
|
/**
|
|
@@ -567,9 +607,10 @@ Promise API (in the `promises` namespace like Node.js's
|
|
|
567
607
|
*
|
|
568
608
|
* @param {string} file Configuration file name.
|
|
569
609
|
* @param {ConfigurationParser[]} [parsers] Parsing function(s).
|
|
610
|
+
* @param {Object} [fs] File system implementation.
|
|
570
611
|
* @returns {Promise<Configuration>} Configuration object.
|
|
571
612
|
*/
|
|
572
|
-
function readConfig(file, parsers) { ... }
|
|
613
|
+
function readConfig(file, parsers, fs) { ... }
|
|
573
614
|
```
|
|
574
615
|
|
|
575
616
|
#### file
|
|
@@ -597,9 +638,19 @@ should come before flexible parsers.
|
|
|
597
638
|
For example:
|
|
598
639
|
|
|
599
640
|
```js
|
|
600
|
-
[ JSON.parse, require("toml").parse, require("js-yaml").
|
|
641
|
+
[ JSON.parse, require("toml").parse, require("js-yaml").load ]
|
|
601
642
|
```
|
|
602
643
|
|
|
644
|
+
#### fs
|
|
645
|
+
|
|
646
|
+
Type: *Optional* `Object` implementing the [file system API](https://nodejs.org/api/fs.html)
|
|
647
|
+
|
|
648
|
+
In advanced scenarios, it may be desirable to bypass the default file system API.
|
|
649
|
+
If a custom file system implementation is provided, `markdownlint` will use that
|
|
650
|
+
instead of invoking `require("fs")`.
|
|
651
|
+
|
|
652
|
+
Note: The only methods called are `readFile`, `readFileSync`, `access`, and `accessSync`.
|
|
653
|
+
|
|
603
654
|
#### callback
|
|
604
655
|
|
|
605
656
|
Type: `Function` taking (`Error`, `Object`)
|
|
@@ -640,11 +691,11 @@ Output:
|
|
|
640
691
|
bad.string: 3: MD010/no-hard-tabs Hard tabs [Column: 19]
|
|
641
692
|
bad.string: 1: MD018/no-missing-space-atx No space after hash on atx style heading [Context: "#bad.string"]
|
|
642
693
|
bad.string: 3: MD018/no-missing-space-atx No space after hash on atx style heading [Context: "#This string fails some rules."]
|
|
643
|
-
bad.string: 1: MD041/first-line-heading/first-line-h1 First line in file should be a top
|
|
694
|
+
bad.string: 1: MD041/first-line-heading/first-line-h1 First line in a file should be a top-level heading [Context: "#bad.string"]
|
|
644
695
|
bad.md: 3: MD010/no-hard-tabs Hard tabs [Column: 17]
|
|
645
696
|
bad.md: 1: MD018/no-missing-space-atx No space after hash on atx style heading [Context: "#bad.md"]
|
|
646
697
|
bad.md: 3: MD018/no-missing-space-atx No space after hash on atx style heading [Context: "#This file fails some rules."]
|
|
647
|
-
bad.md: 1: MD041/first-line-heading/first-line-h1 First line in file should be a top
|
|
698
|
+
bad.md: 1: MD041/first-line-heading/first-line-h1 First line in a file should be a top-level heading [Context: "#bad.md"]
|
|
648
699
|
```
|
|
649
700
|
|
|
650
701
|
Or invoke `markdownlint.sync` for a synchronous call:
|
|
@@ -693,7 +744,7 @@ Output:
|
|
|
693
744
|
"errorRange": [ 1, 2 ] },
|
|
694
745
|
{ "lineNumber": 1,
|
|
695
746
|
"ruleNames": [ "MD041", "first-line-heading", "first-line-h1" ],
|
|
696
|
-
"ruleDescription": "First line in file should be a top
|
|
747
|
+
"ruleDescription": "First line in a file should be a top-level heading",
|
|
697
748
|
"ruleInformation": "https://github.com/DavidAnson/markdownlint/blob/v0.0.0/doc/Rules.md#md041",
|
|
698
749
|
"errorDetail": null,
|
|
699
750
|
"errorContext": "#bad.md",
|
|
@@ -732,7 +783,7 @@ Output:
|
|
|
732
783
|
bad.md: 3: MD010/no-hard-tabs Hard tabs [Column: 17]
|
|
733
784
|
bad.md: 1: MD018/no-missing-space-atx No space after hash on atx style heading [Context: "#bad.md"]
|
|
734
785
|
bad.md: 3: MD018/no-missing-space-atx No space after hash on atx style heading [Context: "#This file fails some rules."]
|
|
735
|
-
bad.md: 1: MD041/first-line-heading/first-line-h1 First line in file should be a top
|
|
786
|
+
bad.md: 1: MD041/first-line-heading/first-line-h1 First line in a file should be a top-level heading [Context: "#bad.md"]
|
|
736
787
|
[00:00:00] Finished 'markdownlint' after 10 ms
|
|
737
788
|
```
|
|
738
789
|
|
|
@@ -773,7 +824,7 @@ Warning:
|
|
|
773
824
|
bad.md: 3: MD010/no-hard-tabs Hard tabs [Column: 17]
|
|
774
825
|
bad.md: 1: MD018/no-missing-space-atx No space after hash on atx style heading [Context: "#bad.md"]
|
|
775
826
|
bad.md: 3: MD018/no-missing-space-atx No space after hash on atx style heading [Context: "#This file fails some rules."]
|
|
776
|
-
bad.md: 1: MD041/first-line-heading/first-line-h1 First line in file should be a top
|
|
827
|
+
bad.md: 1: MD041/first-line-heading/first-line-h1 First line in a file should be a top-level heading [Context: "#bad.md"]
|
|
777
828
|
Use --force to continue.
|
|
778
829
|
```
|
|
779
830
|
|
|
@@ -807,7 +858,8 @@ const results = window.markdownlint.sync(options).toString();
|
|
|
807
858
|
|
|
808
859
|
## Examples
|
|
809
860
|
|
|
810
|
-
For ideas how to integrate `markdownlint` into your workflow, refer to the
|
|
861
|
+
For ideas how to integrate `markdownlint` into your workflow, refer to the
|
|
862
|
+
following projects or one of the tools in the [Related section](#Related):
|
|
811
863
|
|
|
812
864
|
* [.NET Documentation](https://docs.microsoft.com/en-us/dotnet/) ([Search repository](https://github.com/dotnet/docs/search?q=markdownlint))
|
|
813
865
|
* [ally.js](https://allyjs.io/) ([Search repository](https://github.com/medialize/ally.js/search?q=markdownlint))
|
|
@@ -815,12 +867,12 @@ For ideas how to integrate `markdownlint` into your workflow, refer to the follo
|
|
|
815
867
|
* [CodiMD](https://github.com/hackmdio/codimd) ([Search repository](https://github.com/hackmdio/codimd/search?q=markdownlint))
|
|
816
868
|
* [ESLint](https://eslint.org/) ([Search repository](https://github.com/eslint/eslint/search?q=markdownlint))
|
|
817
869
|
* [Garden React Components](https://zendeskgarden.github.io/react-components/) ([Search repository](https://github.com/zendeskgarden/react-components/search?q=markdownlint))
|
|
870
|
+
* [MDN Web Docs](https://developer.mozilla.org/) ([Search repository](https://github.com/mdn/content/search?q=markdownlint))
|
|
818
871
|
* [MkDocs](https://www.mkdocs.org/) ([Search repository](https://github.com/mkdocs/mkdocs/search?q=markdownlint))
|
|
819
872
|
* [Mocha](https://mochajs.org/) ([Search repository](https://github.com/mochajs/mocha/search?q=markdownlint))
|
|
820
873
|
* [Reactable](https://glittershark.github.io/reactable/) ([Search repository](https://github.com/glittershark/reactable/search?q=markdownlint))
|
|
821
874
|
* [Sinon.JS](https://sinonjs.org/) ([Search repository](https://github.com/sinonjs/sinon/search?q=markdownlint))
|
|
822
875
|
* [TestCafe](https://devexpress.github.io/testcafe/) ([Search repository](https://github.com/DevExpress/testcafe/search?q=markdownlint))
|
|
823
|
-
* [TypeScript Handbook](https://www.typescriptlang.org/docs/handbook/basic-types.html) ([Search repository](https://github.com/Microsoft/TypeScript-Handbook/search?q=markdownlint))
|
|
824
876
|
* [V8](https://v8.dev/) ([Search repository](https://github.com/v8/v8.dev/search?q=markdownlint))
|
|
825
877
|
* [webhint](https://webhint.io/) ([Search repository](https://github.com/webhintio/hint/search?q=markdownlint))
|
|
826
878
|
* [webpack](https://webpack.js.org/) ([Search repository](https://github.com/webpack/webpack.js.org/search?q=markdownlint))
|
|
@@ -906,10 +958,18 @@ See [CONTRIBUTING.md](CONTRIBUTING.md) for more information.
|
|
|
906
958
|
to fix in browser demo, allow custom rules in `.markdownlint.json` schema, improve
|
|
907
959
|
MD042/MD044, improve documentation, update dependencies.
|
|
908
960
|
* 0.21.1 - Improve MD011/MD031, export `getVersion` API.
|
|
961
|
+
* 0.22.0 - Allow `extends` in config to reference installed packages by name, add
|
|
962
|
+
`markdownlint-disable-next-line` inline comment, support JSON front matter, improve
|
|
963
|
+
MD009/MD026/MD028/MD043, update dependencies (including `markdown-it` to v12).
|
|
964
|
+
* 0.23.0 - Add comprehensive example `.markdownlint.jsonc`/`.markdownlint.yaml` files, add fix
|
|
965
|
+
information for MD004/ul-style, improve MD018/MD019/MD020/MD021/MD037/MD041, improve
|
|
966
|
+
HTML comment handling, update test runner and test suite, update dependencies.
|
|
967
|
+
* 0.23.1 - Work around lack of webpack support for dynamic calls to `require` (`.resolve`).
|
|
968
|
+
* 0.24.0 - Remove support for end-of-life Node version 10, add support for custom file system
|
|
969
|
+
module, improve MD010/MD011/MD037/MD043/MD044, improve TypeScript declaration file
|
|
970
|
+
and JSON schema, update dependencies.
|
|
909
971
|
|
|
910
972
|
[npm-image]: https://img.shields.io/npm/v/markdownlint.svg
|
|
911
973
|
[npm-url]: https://www.npmjs.com/package/markdownlint
|
|
912
|
-
[ci-image]: https://github.com/DavidAnson/markdownlint/workflows/CI/badge.svg?branch=main
|
|
913
|
-
[ci-url]: https://github.com/DavidAnson/markdownlint/actions?query=branch%3Amain
|
|
914
974
|
[license-image]: https://img.shields.io/npm/l/markdownlint.svg
|
|
915
975
|
[license-url]: https://opensource.org/licenses/MIT
|