markdownlint 0.25.0 → 0.26.1

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 (51) hide show
  1. package/CONTRIBUTING.md +2 -0
  2. package/LICENSE +1 -1
  3. package/README.md +125 -83
  4. package/demo/markdownlint-browser.js +1719 -1269
  5. package/doc/Rules.md +133 -15
  6. package/helpers/LICENSE +1 -1
  7. package/helpers/helpers.js +427 -192
  8. package/helpers/package.json +6 -2
  9. package/lib/cache.js +15 -25
  10. package/lib/constants.js +1 -1
  11. package/lib/markdownlint.d.ts +21 -17
  12. package/lib/markdownlint.js +237 -146
  13. package/lib/md004.js +4 -4
  14. package/lib/md005.js +4 -4
  15. package/lib/md006.js +4 -4
  16. package/lib/md007.js +4 -4
  17. package/lib/md009.js +20 -13
  18. package/lib/md010.js +15 -2
  19. package/lib/md011.js +2 -2
  20. package/lib/md013.js +4 -5
  21. package/lib/md014.js +4 -4
  22. package/lib/md021.js +3 -1
  23. package/lib/md026.js +1 -1
  24. package/lib/md027.js +2 -2
  25. package/lib/md028.js +2 -2
  26. package/lib/md029.js +5 -4
  27. package/lib/md030.js +4 -4
  28. package/lib/md031.js +2 -2
  29. package/lib/md032.js +3 -2
  30. package/lib/md033.js +2 -3
  31. package/lib/md034.js +2 -2
  32. package/lib/md035.js +7 -2
  33. package/lib/md036.js +2 -2
  34. package/lib/md038.js +7 -4
  35. package/lib/md039.js +6 -4
  36. package/lib/md042.js +17 -10
  37. package/lib/md043.js +2 -2
  38. package/lib/md044.js +20 -9
  39. package/lib/md046.js +14 -13
  40. package/lib/md048.js +13 -14
  41. package/lib/md049-md050.js +73 -0
  42. package/lib/md051.js +87 -0
  43. package/lib/md052.js +35 -0
  44. package/lib/md053.js +52 -0
  45. package/lib/rules.js +6 -4
  46. package/package.json +36 -29
  47. package/schema/.markdownlint.jsonc +15 -2
  48. package/schema/.markdownlint.yaml +14 -1
  49. package/schema/markdownlint-config-schema.json +119 -737
  50. package/lib/md049.js +0 -45
  51. 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/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  The MIT License (MIT)
2
2
 
3
- Copyright (c) 2015-2021 David Anson
3
+ Copyright (c) 2015-2022 David Anson
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
package/README.md CHANGED
@@ -43,9 +43,9 @@ 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
51
  * Ruby
@@ -106,6 +106,9 @@ playground for learning and exploring.
106
106
  * **[MD048](doc/Rules.md#md048)** *code-fence-style* - Code fence style
107
107
  * **[MD049](doc/Rules.md#md049)** *emphasis-style* - Emphasis style should be consistent
108
108
  * **[MD050](doc/Rules.md#md050)** *strong-style* - Strong style should be consistent
109
+ * **[MD051](doc/Rules.md#md051)** *link-fragments* - Link fragments should be valid
110
+ * **[MD052](doc/Rules.md#md052)** *reference-links-images* - Reference links and images should use a label that is defined
111
+ * **[MD053](doc/Rules.md#md053)** *link-image-reference-definitions* - Link and image reference definitions should be needed
109
112
 
110
113
  <!-- markdownlint-restore -->
111
114
 
@@ -137,11 +140,11 @@ rules at once.
137
140
  MD023, MD024, MD025, MD026, MD036, MD041, MD043
138
141
  * **hr** - MD035
139
142
  * **html** - MD033
140
- * **images** - MD045
143
+ * **images** - MD045, MD052, MD053
141
144
  * **indentation** - MD005, MD006, MD007, MD027
142
145
  * **language** - MD040
143
146
  * **line_length** - MD013
144
- * **links** - MD011, MD034, MD039, MD042
147
+ * **links** - MD011, MD034, MD039, MD042, MD051, MD052, MD053
145
148
  * **ol** - MD029, MD030, MD032
146
149
  * **spaces** - MD018, MD019, MD020, MD021, MD023
147
150
  * **spelling** - MD044
@@ -167,11 +170,13 @@ appear in the final markup):
167
170
 
168
171
  * Disable all rules: `<!-- markdownlint-disable -->`
169
172
  * Enable all rules: `<!-- markdownlint-enable -->`
170
- * Disable all rules for the next line only:
171
- `<!-- markdownlint-disable-next-line -->`
173
+ * Disable all rules for the current line: `<!-- markdownlint-disable-line -->`
174
+ * Disable all rules for the next line: `<!-- markdownlint-disable-next-line -->`
172
175
  * Disable one or more rules by name: `<!-- markdownlint-disable MD001 MD005 -->`
173
176
  * Enable one or more rules by name: `<!-- markdownlint-enable MD001 MD005 -->`
174
- * Disable one or more rules by name for the next line only:
177
+ * Disable one or more rules by name for the current line:
178
+ `<!-- markdownlint-disable-line MD001 MD005 -->`
179
+ * Disable one or more rules by name for the next line:
175
180
  `<!-- markdownlint-disable-next-line MD001 MD005 -->`
176
181
  * Capture the current rule configuration: `<!-- markdownlint-capture -->`
177
182
  * Restore the captured rule configuration: `<!-- markdownlint-restore -->`
@@ -185,6 +190,12 @@ deliberate space * in * emphasis
185
190
 
186
191
  Or:
187
192
 
193
+ ```markdown
194
+ deliberate space * in * emphasis <!-- markdownlint-disable-line no-space-in-emphasis -->
195
+ ```
196
+
197
+ Or:
198
+
188
199
  ```markdown
189
200
  <!-- markdownlint-disable no-space-in-emphasis -->
190
201
  deliberate space * in * emphasis
@@ -251,8 +262,11 @@ or
251
262
  -->
252
263
  ```
253
264
 
254
- These changes apply to the entire file regardless of where the comment
255
- is located. Multiple such comments (if present) are applied top-to-bottom.
265
+ These changes apply to the entire file regardless of where the comment is
266
+ located. Multiple such comments (if present) are applied top-to-bottom. By
267
+ default, content of `markdownlint-configure-file` is assumed to be JSON, but
268
+ [`options.configParsers`](#optionsconfigparsers) can be used to support
269
+ alternate formats.
256
270
 
257
271
  ## API
258
272
 
@@ -303,60 +317,6 @@ Type: `Object`
303
317
  Configures the function. All properties are optional, but at least one
304
318
  of `files` or `strings` should be set to provide input.
305
319
 
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
320
  ##### options.config
361
321
 
362
322
  Type: `Object` mapping `String` to `Boolean | Object`
@@ -448,6 +408,59 @@ const options = {
448
408
  };
449
409
  ```
450
410
 
411
+ ##### options.configParsers
412
+
413
+ Type: *Optional* `Array` of `Function` taking (`String`) and returning `Object`
414
+
415
+ Array of functions to parse the content of `markdownlint-configure-file` blocks.
416
+
417
+ As shown in the [Configuration](#configuration) section, inline comments can be
418
+ used to customize the [configuration object](#optionsconfig) for a document. By
419
+ default, the `JSON.parse` built-in is used, but custom parsers can be specified.
420
+ Content is passed to each parser function until one returns a value (vs. throwing
421
+ an exception). As such, strict parsers should come before flexible ones.
422
+
423
+ For example:
424
+
425
+ ```js
426
+ [ JSON.parse, require("toml").parse, require("js-yaml").load ]
427
+ ```
428
+
429
+ ##### options.customRules
430
+
431
+ Type: `Array` of `Object`
432
+
433
+ List of custom rules to include with the default rule set for linting.
434
+
435
+ Each array element should define a rule. Rules are typically exported
436
+ by another package, but can be defined locally. Custom rules are
437
+ identified by the
438
+ [keyword `markdownlint-rule` on npm](https://www.npmjs.com/search?q=keywords:markdownlint-rule).
439
+
440
+ Example:
441
+
442
+ ```js
443
+ const extraRules = require("extraRules");
444
+ const options = {
445
+ "customRules": [ extraRules.one, extraRules.two ]
446
+ };
447
+ ```
448
+
449
+ See [CustomRules.md](doc/CustomRules.md) for details about authoring
450
+ custom rules.
451
+
452
+ ##### options.files
453
+
454
+ Type: `Array` of `String`
455
+
456
+ List of files to lint.
457
+
458
+ Each array element should be a single file (via relative or absolute path);
459
+ [globbing](https://en.wikipedia.org/wiki/Glob_%28programming%29) is the
460
+ caller's responsibility.
461
+
462
+ Example: `[ "one.md", "dir/two.md" ]`
463
+
451
464
  ##### options.frontMatter
452
465
 
453
466
  Type: `RegExp`
@@ -478,6 +491,16 @@ title: Title
478
491
 
479
492
  Note: Matches must occur at the start of the file.
480
493
 
494
+ ##### options.fs
495
+
496
+ Type: `Object` implementing the [file system API](https://nodejs.org/api/fs.html)
497
+
498
+ In advanced scenarios, it may be desirable to bypass the default file system API.
499
+ If a custom file system implementation is provided, `markdownlint` will use that
500
+ instead of invoking `require("fs")`.
501
+
502
+ Note: The only methods called are `readFile` and `readFileSync`.
503
+
481
504
  ##### options.handleRuleFailures
482
505
 
483
506
  Type: `Boolean`
@@ -493,6 +516,20 @@ This setting can be useful in the presence of (custom) rules that encounter
493
516
  unexpected syntax and fail. By enabling this option, the linting process
494
517
  is allowed to continue and report any violations that were found.
495
518
 
519
+ ##### options.markdownItPlugins
520
+
521
+ Type: `Array` of `Array` of `Function` and plugin parameters
522
+
523
+ Specifies additional [markdown-it plugins](https://www.npmjs.com/search?q=keywords:markdown-it-plugin)
524
+ to use when parsing input. Plugins can be used to support additional syntax and
525
+ features for advanced scenarios.
526
+
527
+ Each item in the top-level `Array` should be of the form:
528
+
529
+ ```js
530
+ [ require("markdown-it-plugin"), plugin_param_0, plugin_param_1, ... ]
531
+ ```
532
+
496
533
  ##### options.noInlineConfig
497
534
 
498
535
  Type: `Boolean`
@@ -520,36 +557,31 @@ as any additional detail or context that is available. *This is deprecated.*
520
557
 
521
558
  Passing a `resultVersion` of `2` corresponds to a detailed format where each error
522
559
  includes information about the line number, rule names, description, as well as any
523
- additional detail or context that is available. *This is the default.*
560
+ additional detail or context that is available. *This is deprecated.*
524
561
 
525
562
  Passing a `resultVersion` of `3` corresponds to the detailed version `2` format
526
563
  with additional information about how to fix automatically-fixable errors. In this
527
564
  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.
565
+ the first error for each rule). *This is the default.*
537
566
 
538
- Each item in the top-level `Array` should be of the form:
567
+ ##### options.strings
539
568
 
540
- ```js
541
- [ require("markdown-it-plugin"), plugin_param_0, plugin_param_1, ... ]
542
- ```
569
+ Type: `Object` mapping `String` to `String`
543
570
 
544
- ##### options.fs
571
+ Map of identifiers to strings for linting.
545
572
 
546
- Type: `Object` implementing the [file system API](https://nodejs.org/api/fs.html)
573
+ When Markdown content is not available as files, it can be passed as
574
+ strings. The keys of the `strings` object are used to identify each
575
+ input value in the `result` summary.
547
576
 
548
- In advanced scenarios, it may be desirable to bypass the default file system API.
549
- If a custom file system implementation is provided, `markdownlint` will use that
550
- instead of invoking `require("fs")`.
577
+ Example:
551
578
 
552
- Note: The only methods called are `readFile` and `readFileSync`.
579
+ ```json
580
+ {
581
+ "readme": "# README\n...",
582
+ "changelog": "# CHANGELOG\n..."
583
+ }
584
+ ```
553
585
 
554
586
  #### callback
555
587
 
@@ -629,7 +661,8 @@ The `file` is resolved relative to the current working directory. If an `extends
629
661
  key is present once read, its value will be resolved as a path relative to `file`
630
662
  and loaded recursively. Settings from a file referenced by `extends` are applied
631
663
  first, then those of `file` are applied on top (overriding any of the same keys
632
- appearing in the referenced file).
664
+ appearing in the referenced file). If either the `file` or `extends` path begins
665
+ with the `~` directory, it will act as a placeholder for the home directory.
633
666
 
634
667
  #### parsers
635
668
 
@@ -978,6 +1011,15 @@ See [CONTRIBUTING.md](CONTRIBUTING.md) for more information.
978
1011
  * 0.25.0 - Add MD049/MD050 for consistent emphasis/strong style (both auto-fixable), improve
979
1012
  MD007/MD010/MD032/MD033/MD035/MD037/MD039, support asynchronous custom rules,
980
1013
  improve performance, improve CI process, reduce dependencies, update dependencies.
1014
+ * 0.25.1 - Update dependencies for CVE-2022-21670.
1015
+ * 0.26.0 - Add MD051/MD052/MD053 for validating link fragments & reference links/images &
1016
+ link/image reference definitions (MD053 is auto-fixable), improve
1017
+ MD010/MD031/MD035/MD039/MD042/MD044/MD049/MD050, add `markdownlint-disable-line`
1018
+ inline comment, support `~` paths in `readConfig/Sync`, add `configParsers` option,
1019
+ remove support for end-of-life Node version 12, default `resultVersion` to 3, update
1020
+ browser script to use ES2015, simplify JSON schema, address remaining CodeQL issues,
1021
+ improve performance, update dependencies.
1022
+ * 0.26.1 - Improve MD051.
981
1023
 
982
1024
  [npm-image]: https://img.shields.io/npm/v/markdownlint.svg
983
1025
  [npm-url]: https://www.npmjs.com/package/markdownlint