markdownlint 0.25.1 → 0.26.2
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 +2 -0
- package/README.md +126 -83
- package/demo/markdownlint-browser.js +1743 -1288
- package/doc/Rules.md +145 -16
- package/helpers/helpers.js +429 -192
- package/helpers/package.json +6 -2
- package/lib/cache.js +15 -25
- package/lib/constants.js +1 -1
- package/lib/markdownlint.d.ts +21 -17
- package/lib/markdownlint.js +237 -151
- package/lib/md004.js +4 -4
- package/lib/md005.js +4 -4
- package/lib/md006.js +4 -4
- package/lib/md007.js +4 -4
- package/lib/md009.js +20 -13
- package/lib/md010.js +15 -2
- package/lib/md011.js +2 -2
- package/lib/md013.js +4 -5
- package/lib/md014.js +4 -4
- package/lib/md021.js +3 -1
- package/lib/md026.js +1 -1
- package/lib/md027.js +2 -2
- package/lib/md028.js +2 -2
- package/lib/md029.js +5 -4
- package/lib/md030.js +4 -4
- package/lib/md031.js +2 -2
- package/lib/md032.js +7 -7
- package/lib/md033.js +3 -4
- package/lib/md034.js +2 -2
- package/lib/md035.js +7 -2
- package/lib/md036.js +2 -2
- package/lib/md037.js +23 -20
- package/lib/md038.js +7 -4
- package/lib/md039.js +6 -4
- package/lib/md042.js +17 -10
- package/lib/md043.js +2 -2
- package/lib/md044.js +20 -9
- package/lib/md046.js +14 -13
- package/lib/md048.js +13 -14
- package/lib/md049-md050.js +73 -0
- package/lib/md051.js +87 -0
- package/lib/md052.js +35 -0
- package/lib/md053.js +59 -0
- package/lib/rules.js +6 -4
- package/package.json +25 -18
- package/schema/.markdownlint.jsonc +19 -1
- package/schema/.markdownlint.yaml +18 -1
- package/schema/markdownlint-config-schema.json +126 -728
- package/lib/md049.js +0 -45
- package/lib/md050.js +0 -45
package/CONTRIBUTING.md
CHANGED
|
@@ -28,6 +28,8 @@ When running tests, `test/*.md` files are enumerated, linted, and fail if any vi
|
|
|
28
28
|
For example, the line `### Heading {MD001}` is expected to trigger the rule `MD001`.
|
|
29
29
|
For cases where the marker text can not be present on the same line, the syntax `{MD###:#}` can be used to include a line number.
|
|
30
30
|
If `some-test.md` needs custom configuration, a `some-test.json` is used to provide a custom `options.config` for that scenario.
|
|
31
|
+
Tests run by `markdownlint-test-scenarios.js` use [AVA's snapshot feature](https://github.com/avajs/ava/blob/main/docs/04-snapshot-testing.md).
|
|
32
|
+
To update snapshots (for example, after modifying a test file), run `npm run update-snapshots` and include the updated files with the pull request.
|
|
31
33
|
|
|
32
34
|
Lint before sending a pull request by running `npm run lint`.
|
|
33
35
|
There should be no issues.
|
package/README.md
CHANGED
|
@@ -43,11 +43,12 @@ and test cases came directly from that project.
|
|
|
43
43
|
* Editor
|
|
44
44
|
* [vscode-markdownlint extension for VS Code](https://marketplace.visualstudio.com/items?itemName=DavidAnson.vscode-markdownlint)
|
|
45
45
|
* [Sublime Text markdownlint for Sublime Text](https://packagecontrol.io/packages/SublimeLinter-contrib-markdownlint)
|
|
46
|
-
* [linter-node-markdownlint extension for Atom](https://atom.io/packages/linter-node-markdownlint)
|
|
47
46
|
* [coc-markdownlint extension for Vim/Neovim](https://github.com/fannheyward/coc-markdownlint)
|
|
48
47
|
* Tooling
|
|
48
|
+
* [eslint-plugin-markdownlint for the ESLint analyzer](https://github.com/paweldrozd/eslint-plugin-markdownlint)
|
|
49
49
|
* [grunt-markdownlint for the Grunt task runner](https://github.com/sagiegurari/grunt-markdownlint)
|
|
50
50
|
* [Cake.Markdownlint addin for Cake build automation system](https://github.com/cake-contrib/Cake.Markdownlint)
|
|
51
|
+
* [Lombiq Node.js Extensions for MSBuild (.NET builds)](https://github.com/Lombiq/NodeJs-Extensions)
|
|
51
52
|
* Ruby
|
|
52
53
|
* [markdownlint/mdl gem for Ruby](https://rubygems.org/gems/mdl)
|
|
53
54
|
|
|
@@ -106,6 +107,9 @@ playground for learning and exploring.
|
|
|
106
107
|
* **[MD048](doc/Rules.md#md048)** *code-fence-style* - Code fence style
|
|
107
108
|
* **[MD049](doc/Rules.md#md049)** *emphasis-style* - Emphasis style should be consistent
|
|
108
109
|
* **[MD050](doc/Rules.md#md050)** *strong-style* - Strong style should be consistent
|
|
110
|
+
* **[MD051](doc/Rules.md#md051)** *link-fragments* - Link fragments should be valid
|
|
111
|
+
* **[MD052](doc/Rules.md#md052)** *reference-links-images* - Reference links and images should use a label that is defined
|
|
112
|
+
* **[MD053](doc/Rules.md#md053)** *link-image-reference-definitions* - Link and image reference definitions should be needed
|
|
109
113
|
|
|
110
114
|
<!-- markdownlint-restore -->
|
|
111
115
|
|
|
@@ -137,11 +141,11 @@ rules at once.
|
|
|
137
141
|
MD023, MD024, MD025, MD026, MD036, MD041, MD043
|
|
138
142
|
* **hr** - MD035
|
|
139
143
|
* **html** - MD033
|
|
140
|
-
* **images** - MD045
|
|
144
|
+
* **images** - MD045, MD052, MD053
|
|
141
145
|
* **indentation** - MD005, MD006, MD007, MD027
|
|
142
146
|
* **language** - MD040
|
|
143
147
|
* **line_length** - MD013
|
|
144
|
-
* **links** - MD011, MD034, MD039, MD042
|
|
148
|
+
* **links** - MD011, MD034, MD039, MD042, MD051, MD052, MD053
|
|
145
149
|
* **ol** - MD029, MD030, MD032
|
|
146
150
|
* **spaces** - MD018, MD019, MD020, MD021, MD023
|
|
147
151
|
* **spelling** - MD044
|
|
@@ -167,11 +171,13 @@ appear in the final markup):
|
|
|
167
171
|
|
|
168
172
|
* Disable all rules: `<!-- markdownlint-disable -->`
|
|
169
173
|
* Enable all rules: `<!-- markdownlint-enable -->`
|
|
170
|
-
* Disable all rules for the
|
|
171
|
-
|
|
174
|
+
* Disable all rules for the current line: `<!-- markdownlint-disable-line -->`
|
|
175
|
+
* Disable all rules for the next line: `<!-- markdownlint-disable-next-line -->`
|
|
172
176
|
* Disable one or more rules by name: `<!-- markdownlint-disable MD001 MD005 -->`
|
|
173
177
|
* Enable one or more rules by name: `<!-- markdownlint-enable MD001 MD005 -->`
|
|
174
|
-
* Disable one or more rules by name for the
|
|
178
|
+
* Disable one or more rules by name for the current line:
|
|
179
|
+
`<!-- markdownlint-disable-line MD001 MD005 -->`
|
|
180
|
+
* Disable one or more rules by name for the next line:
|
|
175
181
|
`<!-- markdownlint-disable-next-line MD001 MD005 -->`
|
|
176
182
|
* Capture the current rule configuration: `<!-- markdownlint-capture -->`
|
|
177
183
|
* Restore the captured rule configuration: `<!-- markdownlint-restore -->`
|
|
@@ -185,6 +191,12 @@ deliberate space * in * emphasis
|
|
|
185
191
|
|
|
186
192
|
Or:
|
|
187
193
|
|
|
194
|
+
```markdown
|
|
195
|
+
deliberate space * in * emphasis <!-- markdownlint-disable-line no-space-in-emphasis -->
|
|
196
|
+
```
|
|
197
|
+
|
|
198
|
+
Or:
|
|
199
|
+
|
|
188
200
|
```markdown
|
|
189
201
|
<!-- markdownlint-disable no-space-in-emphasis -->
|
|
190
202
|
deliberate space * in * emphasis
|
|
@@ -251,8 +263,11 @@ or
|
|
|
251
263
|
-->
|
|
252
264
|
```
|
|
253
265
|
|
|
254
|
-
These changes apply to the entire file regardless of where the comment
|
|
255
|
-
|
|
266
|
+
These changes apply to the entire file regardless of where the comment is
|
|
267
|
+
located. Multiple such comments (if present) are applied top-to-bottom. By
|
|
268
|
+
default, content of `markdownlint-configure-file` is assumed to be JSON, but
|
|
269
|
+
[`options.configParsers`](#optionsconfigparsers) can be used to support
|
|
270
|
+
alternate formats.
|
|
256
271
|
|
|
257
272
|
## API
|
|
258
273
|
|
|
@@ -303,60 +318,6 @@ Type: `Object`
|
|
|
303
318
|
Configures the function. All properties are optional, but at least one
|
|
304
319
|
of `files` or `strings` should be set to provide input.
|
|
305
320
|
|
|
306
|
-
##### options.customRules
|
|
307
|
-
|
|
308
|
-
Type: `Array` of `Object`
|
|
309
|
-
|
|
310
|
-
List of custom rules to include with the default rule set for linting.
|
|
311
|
-
|
|
312
|
-
Each array element should define a rule. Rules are typically exported
|
|
313
|
-
by another package, but can be defined locally. Custom rules are
|
|
314
|
-
identified by the
|
|
315
|
-
[keyword `markdownlint-rule` on npm](https://www.npmjs.com/search?q=keywords:markdownlint-rule).
|
|
316
|
-
|
|
317
|
-
Example:
|
|
318
|
-
|
|
319
|
-
```js
|
|
320
|
-
const extraRules = require("extraRules");
|
|
321
|
-
const options = {
|
|
322
|
-
"customRules": [ extraRules.one, extraRules.two ]
|
|
323
|
-
};
|
|
324
|
-
```
|
|
325
|
-
|
|
326
|
-
See [CustomRules.md](doc/CustomRules.md) for details about authoring
|
|
327
|
-
custom rules.
|
|
328
|
-
|
|
329
|
-
##### options.files
|
|
330
|
-
|
|
331
|
-
Type: `Array` of `String`
|
|
332
|
-
|
|
333
|
-
List of files to lint.
|
|
334
|
-
|
|
335
|
-
Each array element should be a single file (via relative or absolute path);
|
|
336
|
-
[globbing](https://en.wikipedia.org/wiki/Glob_%28programming%29) is the
|
|
337
|
-
caller's responsibility.
|
|
338
|
-
|
|
339
|
-
Example: `[ "one.md", "dir/two.md" ]`
|
|
340
|
-
|
|
341
|
-
##### options.strings
|
|
342
|
-
|
|
343
|
-
Type: `Object` mapping `String` to `String`
|
|
344
|
-
|
|
345
|
-
Map of identifiers to strings for linting.
|
|
346
|
-
|
|
347
|
-
When Markdown content is not available as files, it can be passed as
|
|
348
|
-
strings. The keys of the `strings` object are used to identify each
|
|
349
|
-
input value in the `result` summary.
|
|
350
|
-
|
|
351
|
-
Example:
|
|
352
|
-
|
|
353
|
-
```json
|
|
354
|
-
{
|
|
355
|
-
"readme": "# README\n...",
|
|
356
|
-
"changelog": "# CHANGELOG\n..."
|
|
357
|
-
}
|
|
358
|
-
```
|
|
359
|
-
|
|
360
321
|
##### options.config
|
|
361
322
|
|
|
362
323
|
Type: `Object` mapping `String` to `Boolean | Object`
|
|
@@ -448,6 +409,59 @@ const options = {
|
|
|
448
409
|
};
|
|
449
410
|
```
|
|
450
411
|
|
|
412
|
+
##### options.configParsers
|
|
413
|
+
|
|
414
|
+
Type: *Optional* `Array` of `Function` taking (`String`) and returning `Object`
|
|
415
|
+
|
|
416
|
+
Array of functions to parse the content of `markdownlint-configure-file` blocks.
|
|
417
|
+
|
|
418
|
+
As shown in the [Configuration](#configuration) section, inline comments can be
|
|
419
|
+
used to customize the [configuration object](#optionsconfig) for a document. By
|
|
420
|
+
default, the `JSON.parse` built-in is used, but custom parsers can be specified.
|
|
421
|
+
Content is passed to each parser function until one returns a value (vs. throwing
|
|
422
|
+
an exception). As such, strict parsers should come before flexible ones.
|
|
423
|
+
|
|
424
|
+
For example:
|
|
425
|
+
|
|
426
|
+
```js
|
|
427
|
+
[ JSON.parse, require("toml").parse, require("js-yaml").load ]
|
|
428
|
+
```
|
|
429
|
+
|
|
430
|
+
##### options.customRules
|
|
431
|
+
|
|
432
|
+
Type: `Array` of `Object`
|
|
433
|
+
|
|
434
|
+
List of custom rules to include with the default rule set for linting.
|
|
435
|
+
|
|
436
|
+
Each array element should define a rule. Rules are typically exported
|
|
437
|
+
by another package, but can be defined locally. Custom rules are
|
|
438
|
+
identified by the
|
|
439
|
+
[keyword `markdownlint-rule` on npm](https://www.npmjs.com/search?q=keywords:markdownlint-rule).
|
|
440
|
+
|
|
441
|
+
Example:
|
|
442
|
+
|
|
443
|
+
```js
|
|
444
|
+
const extraRules = require("extraRules");
|
|
445
|
+
const options = {
|
|
446
|
+
"customRules": [ extraRules.one, extraRules.two ]
|
|
447
|
+
};
|
|
448
|
+
```
|
|
449
|
+
|
|
450
|
+
See [CustomRules.md](doc/CustomRules.md) for details about authoring
|
|
451
|
+
custom rules.
|
|
452
|
+
|
|
453
|
+
##### options.files
|
|
454
|
+
|
|
455
|
+
Type: `Array` of `String`
|
|
456
|
+
|
|
457
|
+
List of files to lint.
|
|
458
|
+
|
|
459
|
+
Each array element should be a single file (via relative or absolute path);
|
|
460
|
+
[globbing](https://en.wikipedia.org/wiki/Glob_%28programming%29) is the
|
|
461
|
+
caller's responsibility.
|
|
462
|
+
|
|
463
|
+
Example: `[ "one.md", "dir/two.md" ]`
|
|
464
|
+
|
|
451
465
|
##### options.frontMatter
|
|
452
466
|
|
|
453
467
|
Type: `RegExp`
|
|
@@ -478,6 +492,16 @@ title: Title
|
|
|
478
492
|
|
|
479
493
|
Note: Matches must occur at the start of the file.
|
|
480
494
|
|
|
495
|
+
##### options.fs
|
|
496
|
+
|
|
497
|
+
Type: `Object` implementing the [file system API](https://nodejs.org/api/fs.html)
|
|
498
|
+
|
|
499
|
+
In advanced scenarios, it may be desirable to bypass the default file system API.
|
|
500
|
+
If a custom file system implementation is provided, `markdownlint` will use that
|
|
501
|
+
instead of invoking `require("fs")`.
|
|
502
|
+
|
|
503
|
+
Note: The only methods called are `readFile` and `readFileSync`.
|
|
504
|
+
|
|
481
505
|
##### options.handleRuleFailures
|
|
482
506
|
|
|
483
507
|
Type: `Boolean`
|
|
@@ -493,6 +517,20 @@ This setting can be useful in the presence of (custom) rules that encounter
|
|
|
493
517
|
unexpected syntax and fail. By enabling this option, the linting process
|
|
494
518
|
is allowed to continue and report any violations that were found.
|
|
495
519
|
|
|
520
|
+
##### options.markdownItPlugins
|
|
521
|
+
|
|
522
|
+
Type: `Array` of `Array` of `Function` and plugin parameters
|
|
523
|
+
|
|
524
|
+
Specifies additional [markdown-it plugins](https://www.npmjs.com/search?q=keywords:markdown-it-plugin)
|
|
525
|
+
to use when parsing input. Plugins can be used to support additional syntax and
|
|
526
|
+
features for advanced scenarios.
|
|
527
|
+
|
|
528
|
+
Each item in the top-level `Array` should be of the form:
|
|
529
|
+
|
|
530
|
+
```js
|
|
531
|
+
[ require("markdown-it-plugin"), plugin_param_0, plugin_param_1, ... ]
|
|
532
|
+
```
|
|
533
|
+
|
|
496
534
|
##### options.noInlineConfig
|
|
497
535
|
|
|
498
536
|
Type: `Boolean`
|
|
@@ -520,36 +558,31 @@ as any additional detail or context that is available. *This is deprecated.*
|
|
|
520
558
|
|
|
521
559
|
Passing a `resultVersion` of `2` corresponds to a detailed format where each error
|
|
522
560
|
includes information about the line number, rule names, description, as well as any
|
|
523
|
-
additional detail or context that is available. *This is
|
|
561
|
+
additional detail or context that is available. *This is deprecated.*
|
|
524
562
|
|
|
525
563
|
Passing a `resultVersion` of `3` corresponds to the detailed version `2` format
|
|
526
564
|
with additional information about how to fix automatically-fixable errors. In this
|
|
527
565
|
mode, all errors that occur on each line are reported (other versions report only
|
|
528
|
-
the first error for each rule).
|
|
529
|
-
|
|
530
|
-
##### options.markdownItPlugins
|
|
531
|
-
|
|
532
|
-
Type: `Array` of `Array` of `Function` and plugin parameters
|
|
533
|
-
|
|
534
|
-
Specifies additional [markdown-it plugins](https://www.npmjs.com/search?q=keywords:markdown-it-plugin)
|
|
535
|
-
to use when parsing input. Plugins can be used to support additional syntax and
|
|
536
|
-
features for advanced scenarios.
|
|
566
|
+
the first error for each rule). *This is the default.*
|
|
537
567
|
|
|
538
|
-
|
|
568
|
+
##### options.strings
|
|
539
569
|
|
|
540
|
-
|
|
541
|
-
[ require("markdown-it-plugin"), plugin_param_0, plugin_param_1, ... ]
|
|
542
|
-
```
|
|
570
|
+
Type: `Object` mapping `String` to `String`
|
|
543
571
|
|
|
544
|
-
|
|
572
|
+
Map of identifiers to strings for linting.
|
|
545
573
|
|
|
546
|
-
|
|
574
|
+
When Markdown content is not available as files, it can be passed as
|
|
575
|
+
strings. The keys of the `strings` object are used to identify each
|
|
576
|
+
input value in the `result` summary.
|
|
547
577
|
|
|
548
|
-
|
|
549
|
-
If a custom file system implementation is provided, `markdownlint` will use that
|
|
550
|
-
instead of invoking `require("fs")`.
|
|
578
|
+
Example:
|
|
551
579
|
|
|
552
|
-
|
|
580
|
+
```json
|
|
581
|
+
{
|
|
582
|
+
"readme": "# README\n...",
|
|
583
|
+
"changelog": "# CHANGELOG\n..."
|
|
584
|
+
}
|
|
585
|
+
```
|
|
553
586
|
|
|
554
587
|
#### callback
|
|
555
588
|
|
|
@@ -629,7 +662,8 @@ The `file` is resolved relative to the current working directory. If an `extends
|
|
|
629
662
|
key is present once read, its value will be resolved as a path relative to `file`
|
|
630
663
|
and loaded recursively. Settings from a file referenced by `extends` are applied
|
|
631
664
|
first, then those of `file` are applied on top (overriding any of the same keys
|
|
632
|
-
appearing in the referenced file).
|
|
665
|
+
appearing in the referenced file). If either the `file` or `extends` path begins
|
|
666
|
+
with the `~` directory, it will act as a placeholder for the home directory.
|
|
633
667
|
|
|
634
668
|
#### parsers
|
|
635
669
|
|
|
@@ -979,6 +1013,15 @@ See [CONTRIBUTING.md](CONTRIBUTING.md) for more information.
|
|
|
979
1013
|
MD007/MD010/MD032/MD033/MD035/MD037/MD039, support asynchronous custom rules,
|
|
980
1014
|
improve performance, improve CI process, reduce dependencies, update dependencies.
|
|
981
1015
|
* 0.25.1 - Update dependencies for CVE-2022-21670.
|
|
1016
|
+
* 0.26.0 - Add MD051/MD052/MD053 for validating link fragments & reference links/images &
|
|
1017
|
+
link/image reference definitions (MD053 is auto-fixable), improve
|
|
1018
|
+
MD010/MD031/MD035/MD039/MD042/MD044/MD049/MD050, add `markdownlint-disable-line`
|
|
1019
|
+
inline comment, support `~` paths in `readConfig/Sync`, add `configParsers` option,
|
|
1020
|
+
remove support for end-of-life Node version 12, default `resultVersion` to 3, update
|
|
1021
|
+
browser script to use ES2015, simplify JSON schema, address remaining CodeQL issues,
|
|
1022
|
+
improve performance, update dependencies.
|
|
1023
|
+
* 0.26.1 - Improve MD051.
|
|
1024
|
+
* 0.26.2 - Improve MD037/MD051/MD053.
|
|
982
1025
|
|
|
983
1026
|
[npm-image]: https://img.shields.io/npm/v/markdownlint.svg
|
|
984
1027
|
[npm-url]: https://www.npmjs.com/package/markdownlint
|