markdownlint 0.38.0 → 0.40.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/CHANGELOG.md +15 -0
- package/CONTRIBUTING.md +1 -1
- package/README.md +144 -75
- package/doc/Rules.md +174 -18
- package/doc/md001.md +14 -0
- package/doc/md009.md +8 -9
- package/doc/md010.md +6 -0
- package/doc/md029.md +2 -0
- package/doc/md033.md +7 -1
- package/doc/md051.md +10 -5
- package/doc/md055.md +1 -1
- package/doc/md056.md +1 -1
- package/doc/md059.md +4 -1
- package/doc/md060.md +118 -0
- package/helpers/README.md +2 -2
- package/helpers/helpers.cjs +171 -15
- package/helpers/micromark-helpers.cjs +11 -7
- package/helpers/package.json +1 -1
- package/lib/cache.mjs +6 -2
- package/lib/configuration-strict.d.ts +1351 -205
- package/lib/constants.mjs +6 -5
- package/lib/defer-require.cjs +2 -0
- package/lib/exports.d.mts +1 -2
- package/lib/exports.mjs +1 -2
- package/lib/markdownit.cjs +2 -1
- package/lib/markdownlint.d.mts +101 -51
- package/lib/markdownlint.mjs +217 -181
- package/lib/md001.mjs +6 -2
- package/lib/md004.mjs +7 -18
- package/lib/md007.mjs +2 -1
- package/lib/md009.mjs +9 -5
- package/lib/md010.mjs +1 -1
- package/lib/md011.mjs +8 -6
- package/lib/md013.mjs +14 -27
- package/lib/md022.mjs +5 -2
- package/lib/md029.mjs +25 -14
- package/lib/md031.mjs +0 -1
- package/lib/md032.mjs +3 -1
- package/lib/md033.mjs +28 -20
- package/lib/md034.mjs +2 -1
- package/lib/md036.mjs +5 -3
- package/lib/md037.mjs +10 -7
- package/lib/md042.mjs +4 -2
- package/lib/md043.mjs +2 -2
- package/lib/md044.mjs +1 -1
- package/lib/md046.mjs +6 -6
- package/lib/md053.mjs +1 -1
- package/lib/md054.mjs +7 -5
- package/lib/md055.mjs +7 -6
- package/lib/md056.mjs +1 -1
- package/lib/md060.mjs +170 -0
- package/lib/micromark-parse.mjs +5 -3
- package/lib/node-imports-browser.mjs +2 -0
- package/lib/parse-configuration.mjs +5 -4
- package/lib/rules.mjs +3 -1
- package/package.json +18 -18
- package/schema/.markdownlint.jsonc +69 -54
- package/schema/.markdownlint.yaml +66 -53
- package/schema/markdownlint-config-schema-strict.json +4709 -1537
- package/schema/markdownlint-config-schema.json +4709 -1537
package/lib/constants.mjs
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
// @ts-check
|
|
2
2
|
|
|
3
|
+
/** @type {string[]} */
|
|
3
4
|
export const deprecatedRuleNames = [];
|
|
4
5
|
export const fixableRuleNames = [
|
|
5
6
|
"MD004", "MD005", "MD007", "MD009", "MD010", "MD011",
|
|
6
7
|
"MD012", "MD014", "MD018", "MD019", "MD020", "MD021",
|
|
7
|
-
"MD022", "MD023", "MD026", "MD027", "
|
|
8
|
-
"MD032", "MD034", "MD037", "MD038", "MD039",
|
|
9
|
-
"MD047", "MD049", "MD050", "MD051", "MD053",
|
|
10
|
-
"MD058"
|
|
8
|
+
"MD022", "MD023", "MD026", "MD027", "MD029", "MD030",
|
|
9
|
+
"MD031", "MD032", "MD034", "MD037", "MD038", "MD039",
|
|
10
|
+
"MD044", "MD047", "MD049", "MD050", "MD051", "MD053",
|
|
11
|
+
"MD054", "MD058"
|
|
11
12
|
];
|
|
12
13
|
export const homepage = "https://github.com/DavidAnson/markdownlint";
|
|
13
|
-
export const version = "0.
|
|
14
|
+
export const version = "0.40.0";
|
package/lib/defer-require.cjs
CHANGED
package/lib/exports.d.mts
CHANGED
|
@@ -3,6 +3,7 @@ export type Configuration = import("./markdownlint.mjs").Configuration;
|
|
|
3
3
|
export type ConfigurationParser = import("./markdownlint.mjs").ConfigurationParser;
|
|
4
4
|
export type ConfigurationStrict = import("./markdownlint.mjs").ConfigurationStrict;
|
|
5
5
|
export type FixInfo = import("./markdownlint.mjs").FixInfo;
|
|
6
|
+
export type FixInfoNormalized = import("./markdownlint.mjs").FixInfoNormalized;
|
|
6
7
|
export type LintCallback = import("./markdownlint.mjs").LintCallback;
|
|
7
8
|
export type LintContentCallback = import("./markdownlint.mjs").LintContentCallback;
|
|
8
9
|
export type LintError = import("./markdownlint.mjs").LintError;
|
|
@@ -23,8 +24,6 @@ export type RuleConfiguration = import("./markdownlint.mjs").RuleConfiguration;
|
|
|
23
24
|
export type RuleFunction = import("./markdownlint.mjs").RuleFunction;
|
|
24
25
|
export type RuleOnError = import("./markdownlint.mjs").RuleOnError;
|
|
25
26
|
export type RuleOnErrorFixInfo = import("./markdownlint.mjs").RuleOnErrorFixInfo;
|
|
26
|
-
export type RuleOnErrorFixInfoNormalized = import("./markdownlint.mjs").RuleOnErrorFixInfoNormalized;
|
|
27
27
|
export type RuleOnErrorInfo = import("./markdownlint.mjs").RuleOnErrorInfo;
|
|
28
28
|
export type RuleParams = import("./markdownlint.mjs").RuleParams;
|
|
29
|
-
export type ToStringCallback = import("./markdownlint.mjs").ToStringCallback;
|
|
30
29
|
export { applyFix, applyFixes, getVersion } from "./markdownlint.mjs";
|
package/lib/exports.mjs
CHANGED
|
@@ -7,6 +7,7 @@ export { resolveModule } from "./resolve-module.cjs";
|
|
|
7
7
|
/** @typedef {import("./markdownlint.mjs").ConfigurationParser} ConfigurationParser */
|
|
8
8
|
/** @typedef {import("./markdownlint.mjs").ConfigurationStrict} ConfigurationStrict */
|
|
9
9
|
/** @typedef {import("./markdownlint.mjs").FixInfo} FixInfo */
|
|
10
|
+
/** @typedef {import("./markdownlint.mjs").FixInfoNormalized} FixInfoNormalized */
|
|
10
11
|
/** @typedef {import("./markdownlint.mjs").LintCallback} LintCallback */
|
|
11
12
|
/** @typedef {import("./markdownlint.mjs").LintContentCallback} LintContentCallback */
|
|
12
13
|
/** @typedef {import("./markdownlint.mjs").LintError} LintError */
|
|
@@ -27,7 +28,5 @@ export { resolveModule } from "./resolve-module.cjs";
|
|
|
27
28
|
/** @typedef {import("./markdownlint.mjs").RuleFunction} RuleFunction */
|
|
28
29
|
/** @typedef {import("./markdownlint.mjs").RuleOnError} RuleOnError */
|
|
29
30
|
/** @typedef {import("./markdownlint.mjs").RuleOnErrorFixInfo} RuleOnErrorFixInfo */
|
|
30
|
-
/** @typedef {import("./markdownlint.mjs").RuleOnErrorFixInfoNormalized} RuleOnErrorFixInfoNormalized */
|
|
31
31
|
/** @typedef {import("./markdownlint.mjs").RuleOnErrorInfo} RuleOnErrorInfo */
|
|
32
32
|
/** @typedef {import("./markdownlint.mjs").RuleParams} RuleParams */
|
|
33
|
-
/** @typedef {import("./markdownlint.mjs").ToStringCallback} ToStringCallback */
|
package/lib/markdownit.cjs
CHANGED
|
@@ -127,6 +127,7 @@ function annotateAndFreezeTokens(tokens, lines) {
|
|
|
127
127
|
}
|
|
128
128
|
// Annotate children with lineNumber
|
|
129
129
|
if (token.children) {
|
|
130
|
+
/** @type {number[]} */
|
|
130
131
|
const codeSpanExtraLines = [];
|
|
131
132
|
if (token.children.some((child) => child.type === "code_inline")) {
|
|
132
133
|
forEachInlineCodeSpan(token.content, (code) => {
|
|
@@ -140,7 +141,7 @@ function annotateAndFreezeTokens(tokens, lines) {
|
|
|
140
141
|
if ((child.type === "softbreak") || (child.type === "hardbreak")) {
|
|
141
142
|
lineNumber++;
|
|
142
143
|
} else if (child.type === "code_inline") {
|
|
143
|
-
lineNumber += codeSpanExtraLines.shift();
|
|
144
|
+
lineNumber += codeSpanExtraLines.shift() || 0;
|
|
144
145
|
}
|
|
145
146
|
}
|
|
146
147
|
}
|
package/lib/markdownlint.d.mts
CHANGED
|
@@ -26,62 +26,91 @@ export function lintSync(options: Options | null): LintResults;
|
|
|
26
26
|
* @param {Configuration} config Configuration object.
|
|
27
27
|
* @param {string} file Configuration file name.
|
|
28
28
|
* @param {ConfigurationParser[] | undefined} parsers Parsing function(s).
|
|
29
|
-
* @param {
|
|
29
|
+
* @param {FsLike} fs File system implementation.
|
|
30
30
|
* @returns {Promise<Configuration>} Configuration object.
|
|
31
31
|
*/
|
|
32
|
-
export function extendConfigPromise(config: Configuration, file: string, parsers: ConfigurationParser[] | undefined, fs:
|
|
32
|
+
export function extendConfigPromise(config: Configuration, file: string, parsers: ConfigurationParser[] | undefined, fs: FsLike): Promise<Configuration>;
|
|
33
33
|
/**
|
|
34
34
|
* Read specified configuration file.
|
|
35
35
|
*
|
|
36
36
|
* @param {string} file Configuration file name.
|
|
37
|
-
* @param {ConfigurationParser[] | ReadConfigCallback} [parsers] Parsing
|
|
38
|
-
*
|
|
39
|
-
* @param {Object} [fs] File system implementation.
|
|
37
|
+
* @param {ConfigurationParser[] | ReadConfigCallback} [parsers] Parsing function(s).
|
|
38
|
+
* @param {FsLike | ReadConfigCallback} [fs] File system implementation.
|
|
40
39
|
* @param {ReadConfigCallback} [callback] Callback (err, result) function.
|
|
41
40
|
* @returns {void}
|
|
42
41
|
*/
|
|
43
|
-
export function readConfigAsync(file: string, parsers?: ConfigurationParser[] | ReadConfigCallback, fs?:
|
|
42
|
+
export function readConfigAsync(file: string, parsers?: ConfigurationParser[] | ReadConfigCallback, fs?: FsLike | ReadConfigCallback, callback?: ReadConfigCallback): void;
|
|
44
43
|
/**
|
|
45
44
|
* Read specified configuration file.
|
|
46
45
|
*
|
|
47
46
|
* @param {string} file Configuration file name.
|
|
48
47
|
* @param {ConfigurationParser[]} [parsers] Parsing function(s).
|
|
49
|
-
* @param {
|
|
48
|
+
* @param {FsLike} [fs] File system implementation.
|
|
50
49
|
* @returns {Promise<Configuration>} Configuration object.
|
|
51
50
|
*/
|
|
52
|
-
export function readConfigPromise(file: string, parsers?: ConfigurationParser[], fs?:
|
|
51
|
+
export function readConfigPromise(file: string, parsers?: ConfigurationParser[], fs?: FsLike): Promise<Configuration>;
|
|
53
52
|
/**
|
|
54
53
|
* Read specified configuration file.
|
|
55
54
|
*
|
|
56
55
|
* @param {string} file Configuration file name.
|
|
57
56
|
* @param {ConfigurationParser[]} [parsers] Parsing function(s).
|
|
58
|
-
* @param {
|
|
57
|
+
* @param {FsLike} [fs] File system implementation.
|
|
59
58
|
* @returns {Configuration} Configuration object.
|
|
60
59
|
*/
|
|
61
|
-
export function readConfigSync(file: string, parsers?: ConfigurationParser[], fs?:
|
|
60
|
+
export function readConfigSync(file: string, parsers?: ConfigurationParser[], fs?: FsLike): Configuration;
|
|
62
61
|
/**
|
|
63
62
|
* Applies the specified fix to a Markdown content line.
|
|
64
63
|
*
|
|
65
64
|
* @param {string} line Line of Markdown content.
|
|
66
|
-
* @param {
|
|
65
|
+
* @param {FixInfo} fixInfo FixInfo instance.
|
|
67
66
|
* @param {string} [lineEnding] Line ending to use.
|
|
68
67
|
* @returns {string | null} Fixed content or null if deleted.
|
|
69
68
|
*/
|
|
70
|
-
export function applyFix(line: string, fixInfo:
|
|
69
|
+
export function applyFix(line: string, fixInfo: FixInfo, lineEnding?: string): string | null;
|
|
71
70
|
/**
|
|
72
71
|
* Applies as many of the specified fixes as possible to Markdown content.
|
|
73
72
|
*
|
|
74
73
|
* @param {string} input Lines of Markdown content.
|
|
75
|
-
* @param {
|
|
74
|
+
* @param {LintError[]} errors LintError instances.
|
|
76
75
|
* @returns {string} Fixed content.
|
|
77
76
|
*/
|
|
78
|
-
export function applyFixes(input: string, errors:
|
|
77
|
+
export function applyFixes(input: string, errors: LintError[]): string;
|
|
79
78
|
/**
|
|
80
79
|
* Gets the (semantic) version of the library.
|
|
81
80
|
*
|
|
82
81
|
* @returns {string} SemVer string.
|
|
83
82
|
*/
|
|
84
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
|
+
};
|
|
85
114
|
/**
|
|
86
115
|
* Result object for getEnabledRulesPerLineNumber.
|
|
87
116
|
*/
|
|
@@ -93,11 +122,36 @@ export type EnabledRulesPerLineNumberResult = {
|
|
|
93
122
|
/**
|
|
94
123
|
* Enabled rules per line number.
|
|
95
124
|
*/
|
|
96
|
-
enabledRulesPerLineNumber:
|
|
125
|
+
enabledRulesPerLineNumber: Map<string, boolean>[];
|
|
97
126
|
/**
|
|
98
127
|
* Enabled rule list.
|
|
99
128
|
*/
|
|
100
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;
|
|
101
155
|
};
|
|
102
156
|
/**
|
|
103
157
|
* Function to implement rule logic.
|
|
@@ -320,27 +374,6 @@ export type RuleOnErrorFixInfo = {
|
|
|
320
374
|
*/
|
|
321
375
|
insertText?: string;
|
|
322
376
|
};
|
|
323
|
-
/**
|
|
324
|
-
* RuleOnErrorInfo with all optional properties present.
|
|
325
|
-
*/
|
|
326
|
-
export type RuleOnErrorFixInfoNormalized = {
|
|
327
|
-
/**
|
|
328
|
-
* Line number (1-based).
|
|
329
|
-
*/
|
|
330
|
-
lineNumber: number;
|
|
331
|
-
/**
|
|
332
|
-
* Column of the fix (1-based).
|
|
333
|
-
*/
|
|
334
|
-
editColumn: number;
|
|
335
|
-
/**
|
|
336
|
-
* Count of characters to delete.
|
|
337
|
-
*/
|
|
338
|
-
deleteCount: number;
|
|
339
|
-
/**
|
|
340
|
-
* Text to insert (after deleting).
|
|
341
|
-
*/
|
|
342
|
-
insertText: string;
|
|
343
|
-
};
|
|
344
377
|
/**
|
|
345
378
|
* Rule definition.
|
|
346
379
|
*/
|
|
@@ -418,7 +451,7 @@ export type Options = {
|
|
|
418
451
|
/**
|
|
419
452
|
* File system implementation.
|
|
420
453
|
*/
|
|
421
|
-
fs?:
|
|
454
|
+
fs?: FsLike;
|
|
422
455
|
/**
|
|
423
456
|
* True to catch exceptions.
|
|
424
457
|
*/
|
|
@@ -431,10 +464,6 @@ export type Options = {
|
|
|
431
464
|
* True to ignore HTML directives.
|
|
432
465
|
*/
|
|
433
466
|
noInlineConfig?: boolean;
|
|
434
|
-
/**
|
|
435
|
-
* Results object version.
|
|
436
|
-
*/
|
|
437
|
-
resultVersion?: number;
|
|
438
467
|
/**
|
|
439
468
|
* Strings to lint.
|
|
440
469
|
*/
|
|
@@ -447,11 +476,7 @@ export type Options = {
|
|
|
447
476
|
*/
|
|
448
477
|
export type Plugin = any[];
|
|
449
478
|
/**
|
|
450
|
-
*
|
|
451
|
-
*/
|
|
452
|
-
export type ToStringCallback = (ruleAliases?: boolean) => string;
|
|
453
|
-
/**
|
|
454
|
-
* Lint results (for resultVersion 3).
|
|
479
|
+
* Lint results.
|
|
455
480
|
*/
|
|
456
481
|
export type LintResults = {
|
|
457
482
|
[x: string]: LintError[];
|
|
@@ -475,23 +500,27 @@ export type LintError = {
|
|
|
475
500
|
/**
|
|
476
501
|
* Link to more information.
|
|
477
502
|
*/
|
|
478
|
-
ruleInformation: string;
|
|
503
|
+
ruleInformation: string | null;
|
|
479
504
|
/**
|
|
480
505
|
* Detail about the error.
|
|
481
506
|
*/
|
|
482
|
-
errorDetail: string;
|
|
507
|
+
errorDetail: string | null;
|
|
483
508
|
/**
|
|
484
509
|
* Context for the error.
|
|
485
510
|
*/
|
|
486
|
-
errorContext: string;
|
|
511
|
+
errorContext: string | null;
|
|
487
512
|
/**
|
|
488
513
|
* Column number (1-based) and length.
|
|
489
514
|
*/
|
|
490
|
-
errorRange: number[];
|
|
515
|
+
errorRange: number[] | null;
|
|
491
516
|
/**
|
|
492
517
|
* Fix information.
|
|
493
518
|
*/
|
|
494
|
-
fixInfo
|
|
519
|
+
fixInfo: FixInfo | null;
|
|
520
|
+
/**
|
|
521
|
+
* Severity of the error.
|
|
522
|
+
*/
|
|
523
|
+
severity: "error" | "warning";
|
|
495
524
|
};
|
|
496
525
|
/**
|
|
497
526
|
* Fix information.
|
|
@@ -514,6 +543,27 @@ export type FixInfo = {
|
|
|
514
543
|
*/
|
|
515
544
|
insertText?: string;
|
|
516
545
|
};
|
|
546
|
+
/**
|
|
547
|
+
* FixInfo with all optional properties present.
|
|
548
|
+
*/
|
|
549
|
+
export type FixInfoNormalized = {
|
|
550
|
+
/**
|
|
551
|
+
* Line number (1-based).
|
|
552
|
+
*/
|
|
553
|
+
lineNumber: number;
|
|
554
|
+
/**
|
|
555
|
+
* Column of the fix (1-based).
|
|
556
|
+
*/
|
|
557
|
+
editColumn: number;
|
|
558
|
+
/**
|
|
559
|
+
* Count of characters to delete.
|
|
560
|
+
*/
|
|
561
|
+
deleteCount: number;
|
|
562
|
+
/**
|
|
563
|
+
* Text to insert (after deleting).
|
|
564
|
+
*/
|
|
565
|
+
insertText: string;
|
|
566
|
+
};
|
|
517
567
|
/**
|
|
518
568
|
* Called with the result of linting a string or document.
|
|
519
569
|
*/
|