markdownlint 0.41.0 → 0.42.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.
Files changed (66) hide show
  1. package/CHANGELOG.md +24 -0
  2. package/CONTRIBUTING.md +62 -77
  3. package/README.md +7 -7
  4. package/doc/CustomRules.md +6 -4
  5. package/doc/Rules.md +87 -36
  6. package/doc/md010.md +0 -1
  7. package/doc/md024.md +1 -1
  8. package/doc/md029.md +11 -1
  9. package/doc/md043.md +47 -9
  10. package/doc/md051.md +19 -19
  11. package/doc/md055.md +6 -3
  12. package/doc/md060.md +3 -2
  13. package/helpers/README.md +2 -2
  14. package/helpers/helpers.cjs +23 -7
  15. package/helpers/micromark-helpers.cjs +8 -12
  16. package/helpers/package.json +1 -5
  17. package/helpers/shared.cjs +1 -1
  18. package/lib/cache.mjs +1 -0
  19. package/lib/configuration-strict.d.ts +124 -112
  20. package/lib/constants.mjs +1 -1
  21. package/lib/defer-require.cjs +1 -0
  22. package/lib/exports.d.mts +29 -1
  23. package/lib/markdownit.cjs +8 -1
  24. package/lib/markdownlint.d.mts +337 -195
  25. package/lib/markdownlint.mjs +83 -87
  26. package/lib/md004.mjs +1 -0
  27. package/lib/md005.mjs +1 -1
  28. package/lib/md007.mjs +2 -2
  29. package/lib/md009.mjs +2 -3
  30. package/lib/md010.mjs +1 -1
  31. package/lib/md011.mjs +10 -7
  32. package/lib/md012.mjs +1 -1
  33. package/lib/md013.mjs +13 -9
  34. package/lib/md018.mjs +1 -1
  35. package/lib/md019-md021.mjs +1 -0
  36. package/lib/md020.mjs +1 -1
  37. package/lib/md022.mjs +6 -6
  38. package/lib/md024.mjs +1 -1
  39. package/lib/md025.mjs +1 -1
  40. package/lib/md027.mjs +1 -1
  41. package/lib/md028.mjs +1 -2
  42. package/lib/md029.mjs +34 -23
  43. package/lib/md030.mjs +4 -4
  44. package/lib/md031.mjs +1 -1
  45. package/lib/md032.mjs +5 -4
  46. package/lib/md033.mjs +1 -1
  47. package/lib/md034.mjs +1 -1
  48. package/lib/md037.mjs +1 -2
  49. package/lib/md039.mjs +5 -1
  50. package/lib/md041.mjs +1 -1
  51. package/lib/md043.mjs +98 -44
  52. package/lib/md044.mjs +2 -2
  53. package/lib/md048.mjs +1 -3
  54. package/lib/md051.mjs +3 -3
  55. package/lib/md055.mjs +11 -1
  56. package/lib/md056.mjs +1 -1
  57. package/lib/md058.mjs +1 -1
  58. package/lib/md060.mjs +24 -4
  59. package/lib/micromark-parse.mjs +3 -2
  60. package/lib/resolve-module.cjs +3 -2
  61. package/lib/resolve-module.d.cts +15 -10
  62. package/package.json +33 -34
  63. package/schema/.markdownlint.jsonc +54 -54
  64. package/schema/.markdownlint.yaml +76 -76
  65. package/schema/markdownlint-config-schema-strict.json +126 -118
  66. package/schema/markdownlint-config-schema.json +126 -118
@@ -1,3 +1,45 @@
1
+ export type RemoveFrontMatterResult = {
2
+ /**
3
+ * Markdown content.
4
+ */
5
+ content: string;
6
+ /**
7
+ * Front matter lines.
8
+ */
9
+ frontMatterLines: string[];
10
+ };
11
+ export type GetEffectiveConfigResult = {
12
+ /**
13
+ * Effective configuration.
14
+ */
15
+ effectiveConfig: Configuration;
16
+ /**
17
+ * Rules enabled.
18
+ */
19
+ rulesEnabled: Map<string, boolean>;
20
+ /**
21
+ * Rules severity.
22
+ */
23
+ rulesSeverity: Map<string, "error" | "warning">;
24
+ };
25
+ export type EnabledRulesPerLineNumberResult = {
26
+ /**
27
+ * Effective configuration.
28
+ */
29
+ effectiveConfig: Configuration;
30
+ /**
31
+ * Enabled rules per line number.
32
+ */
33
+ enabledRulesPerLineNumber: Map<string, boolean>[];
34
+ /**
35
+ * Enabled rule list.
36
+ */
37
+ enabledRuleList: Rule[];
38
+ /**
39
+ * Rules severity.
40
+ */
41
+ rulesSeverity: Map<string, "error" | "warning">;
42
+ };
1
43
  /**
2
44
  * Lint specified Markdown files.
3
45
  *
@@ -5,21 +47,39 @@
5
47
  * @param {LintCallback} callback Callback (err, result) function.
6
48
  * @returns {void}
7
49
  */
8
- export function lintAsync(options: Options | null, callback: LintCallback): void;
50
+ export declare function lintAsync(options: Options | null, callback: LintCallback): void;
9
51
  /**
10
52
  * Lint specified Markdown files.
11
53
  *
12
54
  * @param {Options | null} options Configuration options.
13
55
  * @returns {Promise<LintResults>} Results object.
14
56
  */
15
- export function lintPromise(options: Options | null): Promise<LintResults>;
57
+ export declare function lintPromise(options: Options | null): Promise<LintResults>;
16
58
  /**
17
59
  * Lint specified Markdown files.
18
60
  *
19
61
  * @param {Options | null} options Configuration options.
20
62
  * @returns {LintResults} Results object.
21
63
  */
22
- export function lintSync(options: Options | null): LintResults;
64
+ export declare function lintSync(options: Options | null): LintResults;
65
+ export type FsLike = {
66
+ /**
67
+ * access method.
68
+ */
69
+ access: (path: string, callback: (err: Error) => void) => void;
70
+ /**
71
+ * accessSync method.
72
+ */
73
+ accessSync: (path: string) => void;
74
+ /**
75
+ * readFile method.
76
+ */
77
+ readFile: (path: string, encoding: string, callback: (err: Error, data: string) => void) => void;
78
+ /**
79
+ * readFileSync method.
80
+ */
81
+ readFileSync: (path: string, encoding: string) => string;
82
+ };
23
83
  /**
24
84
  * Extend specified configuration object.
25
85
  *
@@ -29,7 +89,7 @@ export function lintSync(options: Options | null): LintResults;
29
89
  * @param {FsLike} fs File system implementation.
30
90
  * @returns {Promise<Configuration>} Configuration object.
31
91
  */
32
- export function extendConfigPromise(config: Configuration, file: string, parsers: ConfigurationParser[] | undefined, fs: FsLike): Promise<Configuration>;
92
+ export declare function extendConfigPromise(config: Configuration, file: string, parsers: ConfigurationParser[] | undefined, fs: FsLike): Promise<Configuration>;
33
93
  /**
34
94
  * Read specified configuration file.
35
95
  *
@@ -39,7 +99,7 @@ export function extendConfigPromise(config: Configuration, file: string, parsers
39
99
  * @param {ReadConfigCallback} [callback] Callback (err, result) function.
40
100
  * @returns {void}
41
101
  */
42
- export function readConfigAsync(file: string, parsers?: ConfigurationParser[] | ReadConfigCallback, fs?: FsLike | ReadConfigCallback, callback?: ReadConfigCallback): void;
102
+ export declare function readConfigAsync(file: string, parsers?: ConfigurationParser[] | ReadConfigCallback, fs?: FsLike | ReadConfigCallback, callback?: ReadConfigCallback): void;
43
103
  /**
44
104
  * Read specified configuration file.
45
105
  *
@@ -48,7 +108,7 @@ export function readConfigAsync(file: string, parsers?: ConfigurationParser[] |
48
108
  * @param {FsLike} [fs] File system implementation.
49
109
  * @returns {Promise<Configuration>} Configuration object.
50
110
  */
51
- export function readConfigPromise(file: string, parsers?: ConfigurationParser[], fs?: FsLike): Promise<Configuration>;
111
+ export declare function readConfigPromise(file: string, parsers?: ConfigurationParser[], fs?: FsLike): Promise<Configuration>;
52
112
  /**
53
113
  * Read specified configuration file.
54
114
  *
@@ -57,7 +117,7 @@ export function readConfigPromise(file: string, parsers?: ConfigurationParser[],
57
117
  * @param {FsLike} [fs] File system implementation.
58
118
  * @returns {Configuration} Configuration object.
59
119
  */
60
- export function readConfigSync(file: string, parsers?: ConfigurationParser[], fs?: FsLike): Configuration;
120
+ export declare function readConfigSync(file: string, parsers?: ConfigurationParser[], fs?: FsLike): Configuration;
61
121
  /**
62
122
  * Applies the specified fix to a Markdown content line.
63
123
  *
@@ -66,7 +126,7 @@ export function readConfigSync(file: string, parsers?: ConfigurationParser[], fs
66
126
  * @param {string} [lineEnding] Line ending to use.
67
127
  * @returns {string | null} Fixed content or null if deleted.
68
128
  */
69
- export function applyFix(line: string, fixInfo: FixInfo, lineEnding?: string): string | null;
129
+ export declare function applyFix(line: string, fixInfo: FixInfo, lineEnding?: string): string | null;
70
130
  /**
71
131
  * Applies as many of the specified fixes as possible to Markdown content.
72
132
  *
@@ -74,92 +134,14 @@ export function applyFix(line: string, fixInfo: FixInfo, lineEnding?: string): s
74
134
  * @param {LintError[]} errors LintError instances.
75
135
  * @returns {string} Fixed content.
76
136
  */
77
- export function applyFixes(input: string, errors: LintError[]): string;
137
+ export declare function applyFixes(input: string, errors: LintError[]): string;
78
138
  /**
79
139
  * Gets the (semantic) version of the library.
80
140
  *
81
141
  * @returns {string} SemVer string.
82
142
  */
83
- export function getVersion(): string;
84
- /**
85
- * Result object for removeFrontMatter.
86
- */
87
- export type RemoveFrontMatterResult = {
88
- /**
89
- * Markdown content.
90
- */
91
- content: string;
92
- /**
93
- * Front matter lines.
94
- */
95
- frontMatterLines: string[];
96
- };
97
- /**
98
- * Result object for getEffectiveConfig.
99
- */
100
- export type GetEffectiveConfigResult = {
101
- /**
102
- * Effective configuration.
103
- */
104
- effectiveConfig: Configuration;
105
- /**
106
- * Rules enabled.
107
- */
108
- rulesEnabled: Map<string, boolean>;
109
- /**
110
- * Rules severity.
111
- */
112
- rulesSeverity: Map<string, "error" | "warning">;
113
- };
114
- /**
115
- * Result object for getEnabledRulesPerLineNumber.
116
- */
117
- export type EnabledRulesPerLineNumberResult = {
118
- /**
119
- * Effective configuration.
120
- */
121
- effectiveConfig: Configuration;
122
- /**
123
- * Enabled rules per line number.
124
- */
125
- enabledRulesPerLineNumber: Map<string, boolean>[];
126
- /**
127
- * Enabled rule list.
128
- */
129
- enabledRuleList: Rule[];
130
- /**
131
- * Rules severity.
132
- */
133
- rulesSeverity: Map<string, "error" | "warning">;
134
- };
135
- /**
136
- * Node fs instance (or compatible object).
137
- */
138
- export type FsLike = {
139
- /**
140
- * access method.
141
- */
142
- access: (path: string, callback: (err: Error) => void) => void;
143
- /**
144
- * accessSync method.
145
- */
146
- accessSync: (path: string) => void;
147
- /**
148
- * readFile method.
149
- */
150
- readFile: (path: string, encoding: string, callback: (err: Error, data: string) => void) => void;
151
- /**
152
- * readFileSync method.
153
- */
154
- readFileSync: (path: string, encoding: string) => string;
155
- };
156
- /**
157
- * Function to implement rule logic.
158
- */
143
+ export declare function getVersion(): string;
159
144
  export type RuleFunction = (params: RuleParams, onError: RuleOnError) => void;
160
- /**
161
- * Rule parameters.
162
- */
163
145
  export type RuleParams = {
164
146
  /**
165
147
  * File/string name.
@@ -186,9 +168,6 @@ export type RuleParams = {
186
168
  */
187
169
  version: string;
188
170
  };
189
- /**
190
- * Markdown parser data.
191
- */
192
171
  export type MarkdownParsers = {
193
172
  /**
194
173
  * Markdown parser data from markdown-it (only present when Rule.parser is "markdownit").
@@ -199,27 +178,18 @@ export type MarkdownParsers = {
199
178
  */
200
179
  micromark: ParserMicromark;
201
180
  };
202
- /**
203
- * Markdown parser data from markdown-it.
204
- */
205
181
  export type ParserMarkdownIt = {
206
182
  /**
207
183
  * Token objects from markdown-it.
208
184
  */
209
185
  tokens: MarkdownItToken[];
210
186
  };
211
- /**
212
- * Markdown parser data from micromark.
213
- */
214
187
  export type ParserMicromark = {
215
188
  /**
216
189
  * Token objects from micromark.
217
190
  */
218
191
  tokens: MicromarkToken[];
219
192
  };
220
- /**
221
- * markdown-it base token.
222
- */
223
193
  export type MarkdownItBaseToken = {
224
194
  /**
225
195
  * HTML attributes.
@@ -274,9 +244,6 @@ export type MarkdownItBaseToken = {
274
244
  */
275
245
  type: string;
276
246
  };
277
- /**
278
- * markdown-it extended token.
279
- */
280
247
  export type MarkdownItExtendedToken = {
281
248
  /**
282
249
  * Child nodes.
@@ -291,14 +258,8 @@ export type MarkdownItExtendedToken = {
291
258
  */
292
259
  line: string;
293
260
  };
294
- /**
295
- * markdown-it token.
296
- */
297
261
  export type MarkdownItToken = MarkdownItBaseToken & MarkdownItExtendedToken;
298
262
  export type MicromarkTokenType = import("micromark-util-types").TokenType;
299
- /**
300
- * micromark token.
301
- */
302
263
  export type MicromarkToken = {
303
264
  /**
304
265
  * Token type.
@@ -333,14 +294,12 @@ export type MicromarkToken = {
333
294
  */
334
295
  parent: MicromarkToken | null;
335
296
  };
336
- /**
337
- * Error-reporting callback.
338
- */
339
297
  export type RuleOnError = (onErrorInfo: RuleOnErrorInfo) => void;
340
- /**
341
- * Fix information for RuleOnError callback.
342
- */
343
298
  export type RuleOnErrorInfo = {
299
+ /**
300
+ * True if applies to front matter.
301
+ */
302
+ frontMatter?: boolean;
344
303
  /**
345
304
  * Line number (1-based).
346
305
  */
@@ -348,48 +307,42 @@ export type RuleOnErrorInfo = {
348
307
  /**
349
308
  * Detail about the error.
350
309
  */
351
- detail?: string | undefined;
310
+ detail?: string;
352
311
  /**
353
312
  * Context for the error.
354
313
  */
355
- context?: string | undefined;
314
+ context?: string;
356
315
  /**
357
316
  * Link to more information.
358
317
  */
359
- information?: URL | undefined;
318
+ information?: URL;
360
319
  /**
361
320
  * Column number (1-based) and length.
362
321
  */
363
- range?: number[] | undefined;
322
+ range?: number[];
364
323
  /**
365
324
  * Fix information.
366
325
  */
367
- fixInfo?: RuleOnErrorFixInfo | undefined;
326
+ fixInfo?: RuleOnErrorFixInfo;
368
327
  };
369
- /**
370
- * Fix information for RuleOnErrorInfo.
371
- */
372
328
  export type RuleOnErrorFixInfo = {
373
329
  /**
374
330
  * Line number (1-based).
375
331
  */
376
- lineNumber?: number | undefined;
332
+ lineNumber?: number;
377
333
  /**
378
334
  * Column of the fix (1-based).
379
335
  */
380
- editColumn?: number | undefined;
336
+ editColumn?: number;
381
337
  /**
382
338
  * Count of characters to delete.
383
339
  */
384
- deleteCount?: number | undefined;
340
+ deleteCount?: number;
385
341
  /**
386
342
  * Text to insert (after deleting).
387
343
  */
388
- insertText?: string | undefined;
344
+ insertText?: string;
389
345
  };
390
- /**
391
- * Rule definition.
392
- */
393
346
  export type Rule = {
394
347
  /**
395
348
  * Rule name(s).
@@ -402,7 +355,7 @@ export type Rule = {
402
355
  /**
403
356
  * Link to more information.
404
357
  */
405
- information?: URL | undefined;
358
+ information?: URL;
406
359
  /**
407
360
  * Rule tag(s).
408
361
  */
@@ -414,89 +367,61 @@ export type Rule = {
414
367
  /**
415
368
  * True if asynchronous.
416
369
  */
417
- asynchronous?: boolean | undefined;
370
+ asynchronous?: boolean;
418
371
  /**
419
372
  * Rule implementation.
420
373
  */
421
374
  function: RuleFunction;
422
375
  };
423
- /**
424
- * Method used by the markdown-it parser to parse input.
425
- */
426
376
  export type MarkdownItParse = (src: string, env: Object) => MarkdownItBaseToken[];
427
- /**
428
- * Instance of the markdown-it parser.
429
- */
430
- export type MarkdownIt = {
431
- /**
432
- * Method to parse input.
433
- */
434
- parse: MarkdownItParse;
435
- };
436
- /**
437
- * Gets an instance of the markdown-it parser. Any plugins should already have been loaded.
438
- */
377
+ export type MarkdownIt = import("markdown-it").MarkdownIt;
439
378
  export type MarkdownItFactory = () => MarkdownIt | Promise<MarkdownIt>;
440
- /**
441
- * Configuration options.
442
- */
443
379
  export type Options = {
444
380
  /**
445
381
  * Configuration object.
446
382
  */
447
- config?: import("./configuration.d.ts").Configuration | undefined;
383
+ config?: Configuration;
448
384
  /**
449
385
  * Configuration parsers.
450
386
  */
451
- configParsers?: ConfigurationParser[] | undefined;
387
+ configParsers?: ConfigurationParser[];
452
388
  /**
453
389
  * Custom rules.
454
390
  */
455
- customRules?: Rule | Rule[] | undefined;
391
+ customRules?: Rule[] | Rule;
456
392
  /**
457
393
  * Files to lint.
458
394
  */
459
- files?: string | string[] | undefined;
395
+ files?: string[] | string;
460
396
  /**
461
397
  * Front matter pattern.
462
398
  */
463
- frontMatter?: RegExp | null | undefined;
399
+ frontMatter?: RegExp | null;
464
400
  /**
465
401
  * File system implementation.
466
402
  */
467
- fs?: FsLike | undefined;
403
+ fs?: FsLike;
468
404
  /**
469
405
  * True to catch exceptions.
470
406
  */
471
- handleRuleFailures?: boolean | undefined;
407
+ handleRuleFailures?: boolean;
472
408
  /**
473
409
  * Function to create a markdown-it parser.
474
410
  */
475
- markdownItFactory?: MarkdownItFactory | undefined;
411
+ markdownItFactory?: MarkdownItFactory;
476
412
  /**
477
413
  * True to ignore HTML directives.
478
414
  */
479
- noInlineConfig?: boolean | undefined;
415
+ noInlineConfig?: boolean;
480
416
  /**
481
417
  * Strings to lint.
482
418
  */
483
- strings?: {
484
- [x: string]: string;
485
- } | undefined;
419
+ strings?: Record<string, string>;
486
420
  };
487
- /**
488
- * A markdown-it plugin.
489
- */
490
421
  export type Plugin = Object[];
491
- /**
492
- * Lint results.
493
- */
494
422
  export type LintResults = {
495
- [x: string]: LintError[];
423
+ [k: string]: LintError[];
496
424
  };
497
- /**
498
- * Lint error.
499
- */
500
425
  export type LintError = {
501
426
  /**
502
427
  * Line number (1-based).
@@ -535,30 +460,24 @@ export type LintError = {
535
460
  */
536
461
  severity: "error" | "warning";
537
462
  };
538
- /**
539
- * Fix information.
540
- */
541
463
  export type FixInfo = {
542
464
  /**
543
465
  * Line number (1-based).
544
466
  */
545
- lineNumber?: number | undefined;
467
+ lineNumber?: number;
546
468
  /**
547
469
  * Column of the fix (1-based).
548
470
  */
549
- editColumn?: number | undefined;
471
+ editColumn?: number;
550
472
  /**
551
473
  * Count of characters to delete.
552
474
  */
553
- deleteCount?: number | undefined;
475
+ deleteCount?: number;
554
476
  /**
555
477
  * Text to insert (after deleting).
556
478
  */
557
- insertText?: string | undefined;
479
+ insertText?: string;
558
480
  };
559
- /**
560
- * FixInfo with all optional properties present.
561
- */
562
481
  export type FixInfoNormalized = {
563
482
  /**
564
483
  * Line number (1-based).
@@ -577,39 +496,262 @@ export type FixInfoNormalized = {
577
496
  */
578
497
  insertText: string;
579
498
  };
499
+ export type LintContentCallback = (error: Error | null, result?: LintError[]) => void;
500
+ export type LintCallback = (error: Error | null, results?: LintResults) => void;
501
+ export type Configuration = import("./configuration.d.ts").Configuration;
502
+ export type ConfigurationStrict = import("./configuration-strict.d.ts").ConfigurationStrict;
503
+ export type ConfigurationParser = (text: string) => Configuration;
504
+ export type ReadConfigCallback = (err: Error | null, config?: Configuration) => void;
505
+ export type ResolveConfigExtendsCallback = (err: Error | null, path?: string) => void;
506
+ export type RuleConfiguration = boolean | any;
507
+ /**
508
+ * Function to implement rule logic.
509
+ *
510
+ * @callback RuleFunction
511
+ * @param {RuleParams} params Rule parameters.
512
+ * @param {RuleOnError} onError Error-reporting callback.
513
+ * @returns {void}
514
+ */
515
+ /**
516
+ * Rule parameters.
517
+ *
518
+ * @typedef {Object} RuleParams
519
+ * @property {string} name File/string name.
520
+ * @property {MarkdownParsers} parsers Markdown parser data.
521
+ * @property {readonly string[]} lines File/string lines.
522
+ * @property {readonly string[]} frontMatterLines Front matter lines.
523
+ * @property {RuleConfiguration} config Rule configuration.
524
+ * @property {string} version Version of the markdownlint library.
525
+ */
526
+ /**
527
+ * Markdown parser data.
528
+ *
529
+ * @typedef {Object} MarkdownParsers
530
+ * @property {ParserMarkdownIt} markdownit Markdown parser data from markdown-it (only present when Rule.parser is "markdownit").
531
+ * @property {ParserMicromark} micromark Markdown parser data from micromark (only present when Rule.parser is "micromark").
532
+ */
533
+ /**
534
+ * Markdown parser data from markdown-it.
535
+ *
536
+ * @typedef {Object} ParserMarkdownIt
537
+ * @property {MarkdownItToken[]} tokens Token objects from markdown-it.
538
+ */
539
+ /**
540
+ * Markdown parser data from micromark.
541
+ *
542
+ * @typedef {Object} ParserMicromark
543
+ * @property {MicromarkToken[]} tokens Token objects from micromark.
544
+ */
545
+ /**
546
+ * markdown-it base token.
547
+ *
548
+ * @typedef {Object} MarkdownItBaseToken
549
+ * @property {string[][] | null} attrs HTML attributes.
550
+ * @property {boolean} block Block-level token.
551
+ * @property {MarkdownItBaseToken[] | null} children Child nodes.
552
+ * @property {string} content Tag contents.
553
+ * @property {boolean} hidden Ignore element.
554
+ * @property {string} info Fence info.
555
+ * @property {number} level Nesting level.
556
+ * @property {number[] | null} map Beginning/ending line numbers.
557
+ * @property {string} markup Markup text.
558
+ * @property {Object} meta Arbitrary data.
559
+ * @property {number} nesting Level change.
560
+ * @property {string} tag HTML tag name.
561
+ * @property {string} type Token type.
562
+ */
563
+ /**
564
+ * markdown-it extended token.
565
+ *
566
+ * @typedef {Object} MarkdownItExtendedToken
567
+ * @property {MarkdownItExtendedToken[] | null} children Child nodes.
568
+ * @property {number} lineNumber Line number (1-based).
569
+ * @property {string} line Line content.
570
+ */
571
+ /**
572
+ * markdown-it token.
573
+ *
574
+ * @typedef {MarkdownItBaseToken & MarkdownItExtendedToken} MarkdownItToken
575
+ */
576
+ /** @typedef {import("micromark-util-types").TokenType} MicromarkTokenType */
577
+ /**
578
+ * micromark token.
579
+ *
580
+ * @typedef {Object} MicromarkToken
581
+ * @property {MicromarkTokenType} type Token type.
582
+ * @property {number} startLine Start line (1-based).
583
+ * @property {number} startColumn Start column (1-based).
584
+ * @property {number} endLine End line (1-based).
585
+ * @property {number} endColumn End column (1-based).
586
+ * @property {string} text Token text.
587
+ * @property {MicromarkToken[]} children Child tokens.
588
+ * @property {MicromarkToken | null} parent Parent token.
589
+ */
590
+ /**
591
+ * Error-reporting callback.
592
+ *
593
+ * @callback RuleOnError
594
+ * @param {RuleOnErrorInfo} onErrorInfo Error information.
595
+ * @returns {void}
596
+ */
597
+ /**
598
+ * Fix information for RuleOnError callback.
599
+ *
600
+ * @typedef {Object} RuleOnErrorInfo
601
+ * @property {boolean} [frontMatter] True if applies to front matter.
602
+ * @property {number} lineNumber Line number (1-based).
603
+ * @property {string} [detail] Detail about the error.
604
+ * @property {string} [context] Context for the error.
605
+ * @property {URL} [information] Link to more information.
606
+ * @property {number[]} [range] Column number (1-based) and length.
607
+ * @property {RuleOnErrorFixInfo} [fixInfo] Fix information.
608
+ */
609
+ /**
610
+ * Fix information for RuleOnErrorInfo.
611
+ *
612
+ * @typedef {Object} RuleOnErrorFixInfo
613
+ * @property {number} [lineNumber] Line number (1-based).
614
+ * @property {number} [editColumn] Column of the fix (1-based).
615
+ * @property {number} [deleteCount] Count of characters to delete.
616
+ * @property {string} [insertText] Text to insert (after deleting).
617
+ */
618
+ /**
619
+ * Rule definition.
620
+ *
621
+ * @typedef {Object} Rule
622
+ * @property {string[]} names Rule name(s).
623
+ * @property {string} description Rule description.
624
+ * @property {URL} [information] Link to more information.
625
+ * @property {string[]} tags Rule tag(s).
626
+ * @property {"markdownit" | "micromark" | "none"} parser Parser used.
627
+ * @property {boolean} [asynchronous] True if asynchronous.
628
+ * @property {RuleFunction} function Rule implementation.
629
+ */
630
+ /**
631
+ * Method used by the markdown-it parser to parse input.
632
+ *
633
+ * @callback MarkdownItParse
634
+ * @param {string} src Source string.
635
+ * @param {Object} env Environment sandbox.
636
+ * @returns {MarkdownItBaseToken[]} Tokens.
637
+ */
638
+ /** @typedef {import("markdown-it").MarkdownIt} MarkdownIt */
639
+ /**
640
+ * Gets an instance of the markdown-it parser. Any plugins should already have been loaded.
641
+ *
642
+ * @callback MarkdownItFactory
643
+ * @returns {MarkdownIt|Promise<MarkdownIt>} Instance of the markdown-it parser.
644
+ */
645
+ /**
646
+ * Configuration options.
647
+ *
648
+ * @typedef {Object} Options
649
+ * @property {Configuration} [config] Configuration object.
650
+ * @property {ConfigurationParser[]} [configParsers] Configuration parsers.
651
+ * @property {Rule[] | Rule} [customRules] Custom rules.
652
+ * @property {string[] | string} [files] Files to lint.
653
+ * @property {RegExp | null} [frontMatter] Front matter pattern.
654
+ * @property {FsLike} [fs] File system implementation.
655
+ * @property {boolean} [handleRuleFailures] True to catch exceptions.
656
+ * @property {MarkdownItFactory} [markdownItFactory] Function to create a markdown-it parser.
657
+ * @property {boolean} [noInlineConfig] True to ignore HTML directives.
658
+ * @property {Object.<string, string>} [strings] Strings to lint.
659
+ */
660
+ /**
661
+ * A markdown-it plugin.
662
+ *
663
+ * @typedef {Object[]} Plugin
664
+ */
665
+ /**
666
+ * Lint results.
667
+ *
668
+ * @typedef {{[k: string]: LintError[]}} LintResults
669
+ */
670
+ /**
671
+ * Lint error.
672
+ *
673
+ * @typedef {Object} LintError
674
+ * @property {number} lineNumber Line number (1-based).
675
+ * @property {string[]} ruleNames Rule name(s).
676
+ * @property {string} ruleDescription Rule description.
677
+ * @property {string | null} ruleInformation Link to more information.
678
+ * @property {string | null} errorDetail Detail about the error.
679
+ * @property {string | null} errorContext Context for the error.
680
+ * @property {number[] | null} errorRange Column number (1-based) and length.
681
+ * @property {FixInfo | null} fixInfo Fix information.
682
+ * @property {"error" | "warning"} severity Severity of the error.
683
+ */
684
+ /**
685
+ * Fix information.
686
+ *
687
+ * @typedef {Object} FixInfo
688
+ * @property {number} [lineNumber] Line number (1-based).
689
+ * @property {number} [editColumn] Column of the fix (1-based).
690
+ * @property {number} [deleteCount] Count of characters to delete.
691
+ * @property {string} [insertText] Text to insert (after deleting).
692
+ */
693
+ /**
694
+ * FixInfo with all optional properties present.
695
+ *
696
+ * @typedef {Object} FixInfoNormalized
697
+ * @property {number} lineNumber Line number (1-based).
698
+ * @property {number} editColumn Column of the fix (1-based).
699
+ * @property {number} deleteCount Count of characters to delete.
700
+ * @property {string} insertText Text to insert (after deleting).
701
+ */
580
702
  /**
581
703
  * Called with the result of linting a string or document.
704
+ *
705
+ * @callback LintContentCallback
706
+ * @param {Error | null} error Error iff failed.
707
+ * @param {LintError[]} [result] Result iff successful.
708
+ * @returns {void}
582
709
  */
583
- export type LintContentCallback = (error: Error | null, result?: LintError[] | undefined) => void;
584
710
  /**
585
711
  * Called with the result of the lint function.
712
+ *
713
+ * @callback LintCallback
714
+ * @param {Error | null} error Error object iff failed.
715
+ * @param {LintResults} [results] Lint results iff succeeded.
716
+ * @returns {void}
586
717
  */
587
- export type LintCallback = (error: Error | null, results?: {
588
- [x: string]: LintError[];
589
- } | undefined) => void;
590
718
  /**
591
719
  * Configuration object for linting rules. For the JSON schema, see
592
- * {@link ../schema/markdownlint-config-schema.json}.
720
+ * {@link ../schema/markdownlint-config-schema.json}.
721
+ *
722
+ * @typedef {import("./configuration.d.ts").Configuration} Configuration
593
723
  */
594
- export type Configuration = import("./configuration.d.ts").Configuration;
595
724
  /**
596
725
  * Configuration object for linting rules strictly. For the JSON schema, see
597
- * {@link ../schema/markdownlint-config-schema-strict.json}.
726
+ * {@link ../schema/markdownlint-config-schema-strict.json}.
727
+ *
728
+ * @typedef {import("./configuration-strict.d.ts").ConfigurationStrict} ConfigurationStrict
598
729
  */
599
- export type ConfigurationStrict = import("./configuration-strict.d.ts").ConfigurationStrict;
600
730
  /**
601
731
  * Parses a configuration string and returns a configuration object.
732
+ *
733
+ * @callback ConfigurationParser
734
+ * @param {string} text Configuration string.
735
+ * @returns {Configuration}
602
736
  */
603
- export type ConfigurationParser = (text: string) => Configuration;
604
737
  /**
605
738
  * Called with the result of the readConfig function.
739
+ *
740
+ * @callback ReadConfigCallback
741
+ * @param {Error | null} err Error object or null.
742
+ * @param {Configuration} [config] Configuration object.
743
+ * @returns {void}
606
744
  */
607
- export type ReadConfigCallback = (err: Error | null, config?: import("./configuration.d.ts").Configuration | undefined) => void;
608
745
  /**
609
746
  * Called with the result of the resolveConfigExtends function.
747
+ *
748
+ * @callback ResolveConfigExtendsCallback
749
+ * @param {Error | null} err Error object or null.
750
+ * @param {string} [path] Resolved path to file.
751
+ * @returns {void}
610
752
  */
611
- export type ResolveConfigExtendsCallback = (err: Error | null, path?: string | undefined) => void;
612
753
  /**
613
- * Rule configuration.
754
+ * Rule configuration object.
755
+ *
756
+ * @typedef {boolean | any} RuleConfiguration Rule configuration.
614
757
  */
615
- export type RuleConfiguration = boolean | any;