markdownlint 0.33.0 → 0.34.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 +8 -0
- package/CONTRIBUTING.md +4 -3
- package/demo/markdownlint-browser.js +2730 -1541
- package/doc/CustomRules.md +14 -7
- package/doc/Rules.md +40 -7
- package/doc/md013.md +8 -7
- package/doc/md049.md +3 -0
- package/doc/md050.md +3 -0
- package/doc/md051.md +26 -0
- package/helpers/README.md +5 -3
- package/helpers/helpers.js +5 -5
- package/helpers/micromark.cjs +45 -27
- package/helpers/package.json +2 -2
- package/lib/configuration.d.ts +102 -102
- package/lib/constants.js +1 -1
- package/lib/markdownlint.d.ts +79 -6
- package/lib/markdownlint.js +95 -20
- package/lib/md001.js +3 -0
- package/lib/md003.js +3 -0
- package/lib/md004.js +3 -0
- package/lib/md005.js +9 -1
- package/lib/md007.js +14 -9
- package/lib/md009.js +3 -0
- package/lib/md010.js +4 -1
- package/lib/md011.js +3 -0
- package/lib/md012.js +3 -0
- package/lib/md013.js +3 -0
- package/lib/md014.js +4 -0
- package/lib/md018.js +4 -0
- package/lib/md019.js +3 -0
- package/lib/md020.js +3 -0
- package/lib/md021.js +3 -0
- package/lib/md022.js +10 -2
- package/lib/md023.js +3 -0
- package/lib/md024.js +3 -0
- package/lib/md025.js +3 -0
- package/lib/md026.js +9 -5
- package/lib/md027.js +29 -43
- package/lib/md028.js +31 -14
- package/lib/md029.js +3 -0
- package/lib/md030.js +9 -4
- package/lib/md031.js +3 -0
- package/lib/md032.js +12 -14
- package/lib/md033.js +9 -2
- package/lib/md034.js +31 -5
- package/lib/md035.js +9 -2
- package/lib/md036.js +33 -39
- package/lib/md037.js +10 -2
- package/lib/md038.js +10 -3
- package/lib/md039.js +4 -0
- package/lib/md040.js +26 -21
- package/lib/md041.js +21 -26
- package/lib/md042.js +4 -0
- package/lib/md043.js +3 -0
- package/lib/md044.js +9 -1
- package/lib/md045.js +10 -3
- package/lib/md046.js +14 -7
- package/lib/md047.js +5 -2
- package/lib/md048.js +26 -13
- package/lib/md049-md050.js +26 -7
- package/lib/md051.js +20 -16
- package/lib/md052.js +3 -0
- package/lib/md053.js +3 -0
- package/lib/md054.js +10 -5
- package/lib/md055.js +9 -1
- package/lib/md056.js +9 -1
- package/package.json +17 -22
- package/schema/.markdownlint.jsonc +50 -50
- package/schema/.markdownlint.yaml +50 -50
- package/schema/markdownlint-config-schema.json +104 -104
package/lib/constants.js
CHANGED
package/lib/markdownlint.d.ts
CHANGED
|
@@ -8,7 +8,7 @@ export = markdownlint;
|
|
|
8
8
|
*/
|
|
9
9
|
declare function markdownlint(options: Options | null, callback: LintCallback): void;
|
|
10
10
|
declare namespace markdownlint {
|
|
11
|
-
export { markdownlintSync as sync, readConfig, readConfigSync, getVersion, promises, RuleFunction, RuleParams, MarkdownItToken, RuleOnError, RuleOnErrorInfo, RuleOnErrorFixInfo, Rule, Options, Plugin, ToStringCallback, LintResults, LintError, FixInfo, LintContentCallback, LintCallback, Configuration, RuleConfiguration, ConfigurationParser, ReadConfigCallback, ResolveConfigExtendsCallback };
|
|
11
|
+
export { markdownlintSync as sync, readConfig, readConfigSync, getVersion, promises, RuleFunction, RuleParams, MarkdownParsers, ParserMarkdownIt, ParserMicromark, MarkdownItToken, MicromarkTokenType, MicromarkToken, RuleOnError, RuleOnErrorInfo, RuleOnErrorFixInfo, Rule, Options, Plugin, ToStringCallback, LintResults, LintError, FixInfo, LintContentCallback, LintCallback, Configuration, RuleConfiguration, ConfigurationParser, ReadConfigCallback, ResolveConfigExtendsCallback };
|
|
12
12
|
}
|
|
13
13
|
/**
|
|
14
14
|
* Configuration options.
|
|
@@ -117,24 +117,55 @@ type RuleParams = {
|
|
|
117
117
|
*/
|
|
118
118
|
name: string;
|
|
119
119
|
/**
|
|
120
|
-
*
|
|
120
|
+
* Markdown parser data.
|
|
121
121
|
*/
|
|
122
|
-
|
|
122
|
+
parsers: MarkdownParsers;
|
|
123
123
|
/**
|
|
124
124
|
* File/string lines.
|
|
125
125
|
*/
|
|
126
|
-
lines: string[];
|
|
126
|
+
lines: readonly string[];
|
|
127
127
|
/**
|
|
128
128
|
* Front matter lines.
|
|
129
129
|
*/
|
|
130
|
-
frontMatterLines: string[];
|
|
130
|
+
frontMatterLines: readonly string[];
|
|
131
131
|
/**
|
|
132
132
|
* Rule configuration.
|
|
133
133
|
*/
|
|
134
134
|
config: RuleConfiguration;
|
|
135
135
|
};
|
|
136
136
|
/**
|
|
137
|
-
* Markdown
|
|
137
|
+
* Markdown parser data.
|
|
138
|
+
*/
|
|
139
|
+
type MarkdownParsers = {
|
|
140
|
+
/**
|
|
141
|
+
* Markdown parser data from markdown-it (only present when Rule.parser is "markdownit").
|
|
142
|
+
*/
|
|
143
|
+
markdownit: ParserMarkdownIt;
|
|
144
|
+
/**
|
|
145
|
+
* Markdown parser data from micromark (only present when Rule.parser is "micromark").
|
|
146
|
+
*/
|
|
147
|
+
micromark: ParserMicromark;
|
|
148
|
+
};
|
|
149
|
+
/**
|
|
150
|
+
* Markdown parser data from markdown-it.
|
|
151
|
+
*/
|
|
152
|
+
type ParserMarkdownIt = {
|
|
153
|
+
/**
|
|
154
|
+
* Token objects from markdown-it.
|
|
155
|
+
*/
|
|
156
|
+
tokens: MarkdownItToken[];
|
|
157
|
+
};
|
|
158
|
+
/**
|
|
159
|
+
* Markdown parser data from micromark.
|
|
160
|
+
*/
|
|
161
|
+
type ParserMicromark = {
|
|
162
|
+
/**
|
|
163
|
+
* Token objects from micromark.
|
|
164
|
+
*/
|
|
165
|
+
tokens: MicromarkToken[];
|
|
166
|
+
};
|
|
167
|
+
/**
|
|
168
|
+
* markdown-it token.
|
|
138
169
|
*/
|
|
139
170
|
type MarkdownItToken = {
|
|
140
171
|
/**
|
|
@@ -198,6 +229,44 @@ type MarkdownItToken = {
|
|
|
198
229
|
*/
|
|
199
230
|
line: string;
|
|
200
231
|
};
|
|
232
|
+
type MicromarkTokenType = import("markdownlint-micromark").TokenType;
|
|
233
|
+
/**
|
|
234
|
+
* micromark token.
|
|
235
|
+
*/
|
|
236
|
+
type MicromarkToken = {
|
|
237
|
+
/**
|
|
238
|
+
* Token type.
|
|
239
|
+
*/
|
|
240
|
+
type: MicromarkTokenType;
|
|
241
|
+
/**
|
|
242
|
+
* Start line (1-based).
|
|
243
|
+
*/
|
|
244
|
+
startLine: number;
|
|
245
|
+
/**
|
|
246
|
+
* Start column (1-based).
|
|
247
|
+
*/
|
|
248
|
+
startColumn: number;
|
|
249
|
+
/**
|
|
250
|
+
* End line (1-based).
|
|
251
|
+
*/
|
|
252
|
+
endLine: number;
|
|
253
|
+
/**
|
|
254
|
+
* End column (1-based).
|
|
255
|
+
*/
|
|
256
|
+
endColumn: number;
|
|
257
|
+
/**
|
|
258
|
+
* Token text.
|
|
259
|
+
*/
|
|
260
|
+
text: string;
|
|
261
|
+
/**
|
|
262
|
+
* Child tokens.
|
|
263
|
+
*/
|
|
264
|
+
children: MicromarkToken[];
|
|
265
|
+
/**
|
|
266
|
+
* Parent token.
|
|
267
|
+
*/
|
|
268
|
+
parent: MicromarkToken | null;
|
|
269
|
+
};
|
|
201
270
|
/**
|
|
202
271
|
* Error-reporting callback.
|
|
203
272
|
*/
|
|
@@ -272,6 +341,10 @@ type Rule = {
|
|
|
272
341
|
* Rule tag(s).
|
|
273
342
|
*/
|
|
274
343
|
tags: string[];
|
|
344
|
+
/**
|
|
345
|
+
* Parser used.
|
|
346
|
+
*/
|
|
347
|
+
parser: "markdownit" | "micromark" | "none";
|
|
275
348
|
/**
|
|
276
349
|
* True if asynchronous.
|
|
277
350
|
*/
|
package/lib/markdownlint.js
CHANGED
|
@@ -33,17 +33,16 @@ function validateRuleList(ruleList, synchronous) {
|
|
|
33
33
|
for (const [ index, rule ] of ruleList.entries()) {
|
|
34
34
|
const customIndex = index - rules.length;
|
|
35
35
|
// eslint-disable-next-line no-inner-declarations, jsdoc/require-jsdoc
|
|
36
|
-
function newError(property) {
|
|
36
|
+
function newError(property, value) {
|
|
37
37
|
return new Error(
|
|
38
|
-
|
|
39
|
-
customIndex + " is incorrect.");
|
|
38
|
+
`Property '${property}' of custom rule at index ${customIndex} is incorrect: '${value}'.`);
|
|
40
39
|
}
|
|
41
40
|
for (const property of [ "names", "tags" ]) {
|
|
42
41
|
const value = rule[property];
|
|
43
42
|
if (!result &&
|
|
44
43
|
(!value || !Array.isArray(value) || (value.length === 0) ||
|
|
45
44
|
!value.every(helpers.isString) || value.some(helpers.isEmptyString))) {
|
|
46
|
-
result = newError(property);
|
|
45
|
+
result = newError(property, value);
|
|
47
46
|
}
|
|
48
47
|
}
|
|
49
48
|
for (const propertyInfo of [
|
|
@@ -53,22 +52,31 @@ function validateRuleList(ruleList, synchronous) {
|
|
|
53
52
|
const property = propertyInfo[0];
|
|
54
53
|
const value = rule[property];
|
|
55
54
|
if (!result && (!value || (typeof value !== propertyInfo[1]))) {
|
|
56
|
-
result = newError(property);
|
|
55
|
+
result = newError(property, value);
|
|
57
56
|
}
|
|
58
57
|
}
|
|
58
|
+
if (
|
|
59
|
+
!result &&
|
|
60
|
+
(rule.parser !== undefined) &&
|
|
61
|
+
(rule.parser !== "markdownit") &&
|
|
62
|
+
!((customIndex < 0) && (rule.parser === "micromark")) &&
|
|
63
|
+
(rule.parser !== "none")
|
|
64
|
+
) {
|
|
65
|
+
result = newError("parser", rule.parser);
|
|
66
|
+
}
|
|
59
67
|
if (
|
|
60
68
|
!result &&
|
|
61
69
|
rule.information &&
|
|
62
70
|
!helpers.isUrl(rule.information)
|
|
63
71
|
) {
|
|
64
|
-
result = newError("information");
|
|
72
|
+
result = newError("information", rule.information);
|
|
65
73
|
}
|
|
66
74
|
if (
|
|
67
75
|
!result &&
|
|
68
76
|
(rule.asynchronous !== undefined) &&
|
|
69
77
|
(typeof rule.asynchronous !== "boolean")
|
|
70
78
|
) {
|
|
71
|
-
result = newError("asynchronous");
|
|
79
|
+
result = newError("asynchronous", rule.asynchronous);
|
|
72
80
|
}
|
|
73
81
|
if (!result && rule.asynchronous && synchronous) {
|
|
74
82
|
result = new Error(
|
|
@@ -563,18 +571,26 @@ function lintContent(
|
|
|
563
571
|
const lines = content.split(helpers.newLineRe);
|
|
564
572
|
annotateAndFreezeTokens(markdownitTokens, lines);
|
|
565
573
|
// Create (frozen) parameters for rules
|
|
566
|
-
|
|
574
|
+
/** @type {MarkdownParsers} */
|
|
575
|
+
// @ts-ignore
|
|
576
|
+
const parsersMarkdownIt = Object.freeze({
|
|
567
577
|
"markdownit": Object.freeze({
|
|
568
578
|
"tokens": markdownitTokens
|
|
569
|
-
})
|
|
579
|
+
})
|
|
580
|
+
});
|
|
581
|
+
/** @type {MarkdownParsers} */
|
|
582
|
+
// @ts-ignore
|
|
583
|
+
const parsersMicromark = Object.freeze({
|
|
570
584
|
"micromark": Object.freeze({
|
|
571
585
|
"tokens": micromarkTokens
|
|
572
586
|
})
|
|
573
587
|
});
|
|
588
|
+
/** @type {MarkdownParsers} */
|
|
589
|
+
// @ts-ignore
|
|
590
|
+
const parsersNone = Object.freeze({});
|
|
574
591
|
const paramsBase = {
|
|
575
592
|
name,
|
|
576
|
-
parsers,
|
|
577
|
-
"tokens": markdownitTokens,
|
|
593
|
+
"parsers": parsersMarkdownIt,
|
|
578
594
|
"lines": Object.freeze(lines),
|
|
579
595
|
"frontMatterLines": Object.freeze(frontMatterLines)
|
|
580
596
|
};
|
|
@@ -583,9 +599,9 @@ function lintContent(
|
|
|
583
599
|
const codeBlockAndSpanRanges =
|
|
584
600
|
helpers.codeBlockAndSpanRanges(paramsBase, lineMetadata);
|
|
585
601
|
const flattenedLists =
|
|
586
|
-
helpers.flattenLists(
|
|
602
|
+
helpers.flattenLists(markdownitTokens);
|
|
587
603
|
const referenceLinkImageData =
|
|
588
|
-
helpers.getReferenceLinkImageData(
|
|
604
|
+
helpers.getReferenceLinkImageData(micromarkTokens);
|
|
589
605
|
cache.set({
|
|
590
606
|
codeBlockAndSpanRanges,
|
|
591
607
|
flattenedLists,
|
|
@@ -594,12 +610,27 @@ function lintContent(
|
|
|
594
610
|
});
|
|
595
611
|
// Function to run for each rule
|
|
596
612
|
let results = [];
|
|
597
|
-
|
|
598
|
-
|
|
613
|
+
/**
|
|
614
|
+
* @param {Rule} rule Rule.
|
|
615
|
+
* @returns {Promise<void> | null} Promise.
|
|
616
|
+
*/
|
|
617
|
+
const forRule = (rule) => {
|
|
599
618
|
// Configure rule
|
|
600
619
|
const ruleName = rule.names[0].toUpperCase();
|
|
620
|
+
const tokens = {};
|
|
621
|
+
let parsers = parsersNone;
|
|
622
|
+
if (rule.parser === undefined) {
|
|
623
|
+
tokens.tokens = markdownitTokens;
|
|
624
|
+
parsers = parsersMarkdownIt;
|
|
625
|
+
} else if (rule.parser === "markdownit") {
|
|
626
|
+
parsers = parsersMarkdownIt;
|
|
627
|
+
} else if (rule.parser === "micromark") {
|
|
628
|
+
parsers = parsersMicromark;
|
|
629
|
+
}
|
|
601
630
|
const params = {
|
|
602
631
|
...paramsBase,
|
|
632
|
+
...tokens,
|
|
633
|
+
parsers,
|
|
603
634
|
"config": effectiveConfig[ruleName]
|
|
604
635
|
};
|
|
605
636
|
// eslint-disable-next-line jsdoc/require-jsdoc
|
|
@@ -721,7 +752,7 @@ function lintContent(
|
|
|
721
752
|
}
|
|
722
753
|
}
|
|
723
754
|
return null;
|
|
724
|
-
}
|
|
755
|
+
};
|
|
725
756
|
// eslint-disable-next-line jsdoc/require-jsdoc
|
|
726
757
|
function formatResults() {
|
|
727
758
|
// Sort results by rule name by line number
|
|
@@ -875,6 +906,7 @@ function lintInput(options, synchronous, callback) {
|
|
|
875
906
|
"description": rule.description,
|
|
876
907
|
"information": helpers.cloneIfUrl(rule.information),
|
|
877
908
|
"tags": helpers.cloneIfArray(rule.tags),
|
|
909
|
+
"parser": rule.parser,
|
|
878
910
|
"asynchronous": rule.asynchronous,
|
|
879
911
|
"function": rule.function
|
|
880
912
|
}));
|
|
@@ -1281,19 +1313,45 @@ module.exports = markdownlint;
|
|
|
1281
1313
|
* @returns {void}
|
|
1282
1314
|
*/
|
|
1283
1315
|
|
|
1316
|
+
/* eslint-disable jsdoc/valid-types */
|
|
1317
|
+
|
|
1284
1318
|
/**
|
|
1285
1319
|
* Rule parameters.
|
|
1286
1320
|
*
|
|
1287
1321
|
* @typedef {Object} RuleParams
|
|
1288
1322
|
* @property {string} name File/string name.
|
|
1289
|
-
* @property {
|
|
1290
|
-
* @property {string[]} lines File/string lines.
|
|
1291
|
-
* @property {string[]} frontMatterLines Front matter lines.
|
|
1323
|
+
* @property {MarkdownParsers} parsers Markdown parser data.
|
|
1324
|
+
* @property {readonly string[]} lines File/string lines.
|
|
1325
|
+
* @property {readonly string[]} frontMatterLines Front matter lines.
|
|
1292
1326
|
* @property {RuleConfiguration} config Rule configuration.
|
|
1293
1327
|
*/
|
|
1294
1328
|
|
|
1329
|
+
/* eslint-enable jsdoc/valid-types */
|
|
1330
|
+
|
|
1331
|
+
/**
|
|
1332
|
+
* Markdown parser data.
|
|
1333
|
+
*
|
|
1334
|
+
* @typedef {Object} MarkdownParsers
|
|
1335
|
+
* @property {ParserMarkdownIt} markdownit Markdown parser data from markdown-it (only present when Rule.parser is "markdownit").
|
|
1336
|
+
* @property {ParserMicromark} micromark Markdown parser data from micromark (only present when Rule.parser is "micromark").
|
|
1337
|
+
*/
|
|
1338
|
+
|
|
1295
1339
|
/**
|
|
1296
|
-
* Markdown-
|
|
1340
|
+
* Markdown parser data from markdown-it.
|
|
1341
|
+
*
|
|
1342
|
+
* @typedef {Object} ParserMarkdownIt
|
|
1343
|
+
* @property {MarkdownItToken[]} tokens Token objects from markdown-it.
|
|
1344
|
+
*/
|
|
1345
|
+
|
|
1346
|
+
/**
|
|
1347
|
+
* Markdown parser data from micromark.
|
|
1348
|
+
*
|
|
1349
|
+
* @typedef {Object} ParserMicromark
|
|
1350
|
+
* @property {MicromarkToken[]} tokens Token objects from micromark.
|
|
1351
|
+
*/
|
|
1352
|
+
|
|
1353
|
+
/**
|
|
1354
|
+
* markdown-it token.
|
|
1297
1355
|
*
|
|
1298
1356
|
* @typedef {Object} MarkdownItToken
|
|
1299
1357
|
* @property {string[][]} attrs HTML attributes.
|
|
@@ -1313,6 +1371,22 @@ module.exports = markdownlint;
|
|
|
1313
1371
|
* @property {string} line Line content.
|
|
1314
1372
|
*/
|
|
1315
1373
|
|
|
1374
|
+
/** @typedef {import("markdownlint-micromark").TokenType} MicromarkTokenType */
|
|
1375
|
+
|
|
1376
|
+
/**
|
|
1377
|
+
* micromark token.
|
|
1378
|
+
*
|
|
1379
|
+
* @typedef {Object} MicromarkToken
|
|
1380
|
+
* @property {MicromarkTokenType} type Token type.
|
|
1381
|
+
* @property {number} startLine Start line (1-based).
|
|
1382
|
+
* @property {number} startColumn Start column (1-based).
|
|
1383
|
+
* @property {number} endLine End line (1-based).
|
|
1384
|
+
* @property {number} endColumn End column (1-based).
|
|
1385
|
+
* @property {string} text Token text.
|
|
1386
|
+
* @property {MicromarkToken[]} children Child tokens.
|
|
1387
|
+
* @property {MicromarkToken | null} parent Parent token.
|
|
1388
|
+
*/
|
|
1389
|
+
|
|
1316
1390
|
/**
|
|
1317
1391
|
* Error-reporting callback.
|
|
1318
1392
|
*
|
|
@@ -1351,6 +1425,7 @@ module.exports = markdownlint;
|
|
|
1351
1425
|
* @property {string} description Rule description.
|
|
1352
1426
|
* @property {URL} [information] Link to more information.
|
|
1353
1427
|
* @property {string[]} tags Rule tag(s).
|
|
1428
|
+
* @property {"markdownit" | "micromark" | "none"} parser Parser used.
|
|
1354
1429
|
* @property {boolean} [asynchronous] True if asynchronous.
|
|
1355
1430
|
* @property {RuleFunction} function Rule implementation.
|
|
1356
1431
|
*/
|
package/lib/md001.js
CHANGED
|
@@ -4,10 +4,13 @@
|
|
|
4
4
|
|
|
5
5
|
const { addErrorDetailIf, filterTokens } = require("../helpers");
|
|
6
6
|
|
|
7
|
+
// eslint-disable-next-line jsdoc/valid-types
|
|
8
|
+
/** @type import("./markdownlint").Rule */
|
|
7
9
|
module.exports = {
|
|
8
10
|
"names": [ "MD001", "heading-increment" ],
|
|
9
11
|
"description": "Heading levels should only increment by one level at a time",
|
|
10
12
|
"tags": [ "headings" ],
|
|
13
|
+
"parser": "markdownit",
|
|
11
14
|
"function": function MD001(params, onError) {
|
|
12
15
|
let prevLevel = 0;
|
|
13
16
|
filterTokens(params, "heading_open", function forToken(token) {
|
package/lib/md003.js
CHANGED
|
@@ -5,10 +5,13 @@
|
|
|
5
5
|
const { addErrorDetailIf, filterTokens, headingStyleFor } =
|
|
6
6
|
require("../helpers");
|
|
7
7
|
|
|
8
|
+
// eslint-disable-next-line jsdoc/valid-types
|
|
9
|
+
/** @type import("./markdownlint").Rule */
|
|
8
10
|
module.exports = {
|
|
9
11
|
"names": [ "MD003", "heading-style" ],
|
|
10
12
|
"description": "Heading style",
|
|
11
13
|
"tags": [ "headings" ],
|
|
14
|
+
"parser": "markdownit",
|
|
12
15
|
"function": function MD003(params, onError) {
|
|
13
16
|
let style = String(params.config.style || "consistent");
|
|
14
17
|
filterTokens(params, "heading_open", function forToken(token) {
|
package/lib/md004.js
CHANGED
|
@@ -18,10 +18,13 @@ const differentItemStyle = {
|
|
|
18
18
|
};
|
|
19
19
|
const validStyles = Object.keys(expectedStyleToMarker);
|
|
20
20
|
|
|
21
|
+
// eslint-disable-next-line jsdoc/valid-types
|
|
22
|
+
/** @type import("./markdownlint").Rule */
|
|
21
23
|
module.exports = {
|
|
22
24
|
"names": [ "MD004", "ul-style" ],
|
|
23
25
|
"description": "Unordered list style",
|
|
24
26
|
"tags": [ "bullet", "ul" ],
|
|
27
|
+
"parser": "none",
|
|
25
28
|
"function": function MD004(params, onError) {
|
|
26
29
|
const style = String(params.config.style || "consistent");
|
|
27
30
|
let expectedStyle = style;
|
package/lib/md005.js
CHANGED
|
@@ -5,13 +5,21 @@
|
|
|
5
5
|
const { addError, addErrorDetailIf } = require("../helpers");
|
|
6
6
|
const { filterByTypes, inHtmlFlow } = require("../helpers/micromark.cjs");
|
|
7
7
|
|
|
8
|
+
// eslint-disable-next-line jsdoc/valid-types
|
|
9
|
+
/** @type import("./markdownlint").Rule */
|
|
8
10
|
module.exports = {
|
|
9
11
|
"names": [ "MD005", "list-indent" ],
|
|
10
12
|
"description": "Inconsistent indentation for list items at the same level",
|
|
11
13
|
"tags": [ "bullet", "ul", "indentation" ],
|
|
14
|
+
"parser": "micromark",
|
|
12
15
|
"function": function MD005(params, onError) {
|
|
16
|
+
// eslint-disable-next-line jsdoc/valid-types
|
|
17
|
+
/** @type import("../helpers/micromark.cjs").Token[] */
|
|
18
|
+
const micromarkTokens =
|
|
19
|
+
// @ts-ignore
|
|
20
|
+
params.parsers.micromark.tokens;
|
|
13
21
|
const lists = filterByTypes(
|
|
14
|
-
|
|
22
|
+
micromarkTokens,
|
|
15
23
|
[ "listOrdered", "listUnordered" ]
|
|
16
24
|
).filter((list) => !inHtmlFlow(list));
|
|
17
25
|
for (const list of lists) {
|
package/lib/md007.js
CHANGED
|
@@ -6,36 +6,41 @@ const { addErrorDetailIf } = require("../helpers");
|
|
|
6
6
|
const { filterByTypes, getTokenParentOfType, inHtmlFlow } =
|
|
7
7
|
require("../helpers/micromark.cjs");
|
|
8
8
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
*/
|
|
12
|
-
|
|
9
|
+
// eslint-disable-next-line jsdoc/valid-types
|
|
10
|
+
/** @type import("markdownlint-micromark").TokenType[] */
|
|
13
11
|
const unorderedListTypes =
|
|
14
12
|
[ "blockQuotePrefix", "listItemPrefix", "listUnordered" ];
|
|
13
|
+
// eslint-disable-next-line jsdoc/valid-types
|
|
14
|
+
/** @type import("markdownlint-micromark").TokenType[] */
|
|
15
15
|
const unorderedParentTypes =
|
|
16
16
|
[ "blockQuote", "listOrdered", "listUnordered" ];
|
|
17
17
|
|
|
18
|
+
// eslint-disable-next-line jsdoc/valid-types
|
|
19
|
+
/** @type import("./markdownlint").Rule */
|
|
18
20
|
module.exports = {
|
|
19
21
|
"names": [ "MD007", "ul-indent" ],
|
|
20
22
|
"description": "Unordered list indentation",
|
|
21
23
|
"tags": [ "bullet", "ul", "indentation" ],
|
|
24
|
+
"parser": "micromark",
|
|
22
25
|
"function": function MD007(params, onError) {
|
|
23
26
|
const indent = Number(params.config.indent || 2);
|
|
24
27
|
const startIndented = !!params.config.start_indented;
|
|
25
28
|
const startIndent = Number(params.config.start_indent || indent);
|
|
29
|
+
// eslint-disable-next-line jsdoc/valid-types
|
|
30
|
+
/** @type import("../helpers/micromark.cjs").Token[] */
|
|
31
|
+
const micromarkTokens =
|
|
32
|
+
// @ts-ignore
|
|
33
|
+
params.parsers.micromark.tokens;
|
|
26
34
|
const unorderedListNesting = new Map();
|
|
27
35
|
let lastBlockQuotePrefix = null;
|
|
28
|
-
const tokens = filterByTypes(
|
|
29
|
-
params.parsers.micromark.tokens,
|
|
30
|
-
unorderedListTypes
|
|
31
|
-
);
|
|
36
|
+
const tokens = filterByTypes(micromarkTokens, unorderedListTypes);
|
|
32
37
|
for (const token of tokens) {
|
|
33
38
|
const { endColumn, parent, startColumn, startLine, type } = token;
|
|
34
39
|
if (type === "blockQuotePrefix") {
|
|
35
40
|
lastBlockQuotePrefix = token;
|
|
36
41
|
} else if (type === "listUnordered") {
|
|
37
42
|
let nesting = 0;
|
|
38
|
-
/** @type {Token | null} */
|
|
43
|
+
/** @type {import("../helpers/micromark.cjs").Token | null} */
|
|
39
44
|
let current = token;
|
|
40
45
|
while (
|
|
41
46
|
(current = getTokenParentOfType(current, unorderedParentTypes))
|
package/lib/md009.js
CHANGED
|
@@ -6,10 +6,13 @@ const { addError, filterTokens, forEachLine, includesSorted,
|
|
|
6
6
|
numericSortAscending } = require("../helpers");
|
|
7
7
|
const { lineMetadata } = require("./cache");
|
|
8
8
|
|
|
9
|
+
// eslint-disable-next-line jsdoc/valid-types
|
|
10
|
+
/** @type import("./markdownlint").Rule */
|
|
9
11
|
module.exports = {
|
|
10
12
|
"names": [ "MD009", "no-trailing-spaces" ],
|
|
11
13
|
"description": "Trailing spaces",
|
|
12
14
|
"tags": [ "whitespace" ],
|
|
15
|
+
"parser": "markdownit",
|
|
13
16
|
"function": function MD009(params, onError) {
|
|
14
17
|
let brSpaces = params.config.br_spaces;
|
|
15
18
|
brSpaces = Number((brSpaces === undefined) ? 2 : brSpaces);
|
package/lib/md010.js
CHANGED
|
@@ -8,10 +8,13 @@ const { codeBlockAndSpanRanges, lineMetadata } = require("./cache");
|
|
|
8
8
|
|
|
9
9
|
const tabRe = /\t+/g;
|
|
10
10
|
|
|
11
|
+
// eslint-disable-next-line jsdoc/valid-types
|
|
12
|
+
/** @type import("./markdownlint").Rule */
|
|
11
13
|
module.exports = {
|
|
12
14
|
"names": [ "MD010", "no-hard-tabs" ],
|
|
13
15
|
"description": "Hard tabs",
|
|
14
16
|
"tags": [ "whitespace", "hard_tab" ],
|
|
17
|
+
"parser": "markdownit",
|
|
15
18
|
"function": function MD010(params, onError) {
|
|
16
19
|
const codeBlocks = params.config.code_blocks;
|
|
17
20
|
const includeCode = (codeBlocks === undefined) ? true : !!codeBlocks;
|
|
@@ -44,7 +47,7 @@ module.exports = {
|
|
|
44
47
|
onError,
|
|
45
48
|
lineIndex + 1,
|
|
46
49
|
"Column: " + column,
|
|
47
|
-
|
|
50
|
+
undefined,
|
|
48
51
|
[ column, length ],
|
|
49
52
|
{
|
|
50
53
|
"editColumn": column,
|
package/lib/md011.js
CHANGED
|
@@ -8,10 +8,13 @@ const { codeBlockAndSpanRanges, lineMetadata } = require("./cache");
|
|
|
8
8
|
const reversedLinkRe =
|
|
9
9
|
/(^|[^\\])\(([^()]+)\)\[([^\]^][^\]]*)\](?!\()/g;
|
|
10
10
|
|
|
11
|
+
// eslint-disable-next-line jsdoc/valid-types
|
|
12
|
+
/** @type import("./markdownlint").Rule */
|
|
11
13
|
module.exports = {
|
|
12
14
|
"names": [ "MD011", "no-reversed-links" ],
|
|
13
15
|
"description": "Reversed link syntax",
|
|
14
16
|
"tags": [ "links" ],
|
|
17
|
+
"parser": "none",
|
|
15
18
|
"function": function MD011(params, onError) {
|
|
16
19
|
const exclusions = codeBlockAndSpanRanges();
|
|
17
20
|
forEachLine(lineMetadata(), (line, lineIndex, inCode, onFence) => {
|
package/lib/md012.js
CHANGED
|
@@ -5,10 +5,13 @@
|
|
|
5
5
|
const { addErrorDetailIf, forEachLine } = require("../helpers");
|
|
6
6
|
const { lineMetadata } = require("./cache");
|
|
7
7
|
|
|
8
|
+
// eslint-disable-next-line jsdoc/valid-types
|
|
9
|
+
/** @type import("./markdownlint").Rule */
|
|
8
10
|
module.exports = {
|
|
9
11
|
"names": [ "MD012", "no-multiple-blanks" ],
|
|
10
12
|
"description": "Multiple consecutive blank lines",
|
|
11
13
|
"tags": [ "whitespace", "blank_lines" ],
|
|
14
|
+
"parser": "none",
|
|
12
15
|
"function": function MD012(params, onError) {
|
|
13
16
|
const maximum = Number(params.config.maximum || 1);
|
|
14
17
|
let count = 0;
|
package/lib/md013.js
CHANGED
|
@@ -22,10 +22,13 @@ const tokenTypeMap = {
|
|
|
22
22
|
"text": "T"
|
|
23
23
|
};
|
|
24
24
|
|
|
25
|
+
// eslint-disable-next-line jsdoc/valid-types
|
|
26
|
+
/** @type import("./markdownlint").Rule */
|
|
25
27
|
module.exports = {
|
|
26
28
|
"names": [ "MD013", "line-length" ],
|
|
27
29
|
"description": "Line length",
|
|
28
30
|
"tags": [ "line_length" ],
|
|
31
|
+
"parser": "markdownit",
|
|
29
32
|
"function": function MD013(params, onError) {
|
|
30
33
|
const lineLength = Number(params.config.line_length || 80);
|
|
31
34
|
const headingLineLength =
|
package/lib/md014.js
CHANGED
|
@@ -6,10 +6,13 @@ const { addErrorContext, filterTokens } = require("../helpers");
|
|
|
6
6
|
|
|
7
7
|
const dollarCommandRe = /^(\s*)(\$\s+)/;
|
|
8
8
|
|
|
9
|
+
// eslint-disable-next-line jsdoc/valid-types
|
|
10
|
+
/** @type import("./markdownlint").Rule */
|
|
9
11
|
module.exports = {
|
|
10
12
|
"names": [ "MD014", "commands-show-output" ],
|
|
11
13
|
"description": "Dollar signs used before commands without showing output",
|
|
12
14
|
"tags": [ "code" ],
|
|
15
|
+
"parser": "markdownit",
|
|
13
16
|
"function": function MD014(params, onError) {
|
|
14
17
|
for (const type of [ "code_block", "fence" ]) {
|
|
15
18
|
filterTokens(params, type, (token) => {
|
|
@@ -35,6 +38,7 @@ module.exports = {
|
|
|
35
38
|
const [ i, lineTrim, column, length ] = instance;
|
|
36
39
|
addErrorContext(
|
|
37
40
|
onError,
|
|
41
|
+
// @ts-ignore
|
|
38
42
|
i + 1,
|
|
39
43
|
lineTrim,
|
|
40
44
|
null,
|
package/lib/md018.js
CHANGED
|
@@ -5,16 +5,20 @@
|
|
|
5
5
|
const { addErrorContext, forEachLine } = require("../helpers");
|
|
6
6
|
const { lineMetadata } = require("./cache");
|
|
7
7
|
|
|
8
|
+
// eslint-disable-next-line jsdoc/valid-types
|
|
9
|
+
/** @type import("./markdownlint").Rule */
|
|
8
10
|
module.exports = {
|
|
9
11
|
"names": [ "MD018", "no-missing-space-atx" ],
|
|
10
12
|
"description": "No space after hash on atx style heading",
|
|
11
13
|
"tags": [ "headings", "atx", "spaces" ],
|
|
14
|
+
"parser": "none",
|
|
12
15
|
"function": function MD018(params, onError) {
|
|
13
16
|
forEachLine(lineMetadata(), (line, lineIndex, inCode) => {
|
|
14
17
|
if (!inCode &&
|
|
15
18
|
/^#+[^# \t]/.test(line) &&
|
|
16
19
|
!/#\s*$/.test(line) &&
|
|
17
20
|
!line.startsWith("#️⃣")) {
|
|
21
|
+
// @ts-ignore
|
|
18
22
|
const hashCount = /^#+/.exec(line)[0].length;
|
|
19
23
|
addErrorContext(
|
|
20
24
|
onError,
|
package/lib/md019.js
CHANGED
|
@@ -5,10 +5,13 @@
|
|
|
5
5
|
const { addErrorContext, filterTokens, headingStyleFor } =
|
|
6
6
|
require("../helpers");
|
|
7
7
|
|
|
8
|
+
// eslint-disable-next-line jsdoc/valid-types
|
|
9
|
+
/** @type import("./markdownlint").Rule */
|
|
8
10
|
module.exports = {
|
|
9
11
|
"names": [ "MD019", "no-multiple-space-atx" ],
|
|
10
12
|
"description": "Multiple spaces after hash on atx style heading",
|
|
11
13
|
"tags": [ "headings", "atx", "spaces" ],
|
|
14
|
+
"parser": "markdownit",
|
|
12
15
|
"function": function MD019(params, onError) {
|
|
13
16
|
filterTokens(params, "heading_open", (token) => {
|
|
14
17
|
if (headingStyleFor(token) === "atx") {
|
package/lib/md020.js
CHANGED
|
@@ -5,10 +5,13 @@
|
|
|
5
5
|
const { addErrorContext, forEachLine } = require("../helpers");
|
|
6
6
|
const { lineMetadata } = require("./cache");
|
|
7
7
|
|
|
8
|
+
// eslint-disable-next-line jsdoc/valid-types
|
|
9
|
+
/** @type import("./markdownlint").Rule */
|
|
8
10
|
module.exports = {
|
|
9
11
|
"names": [ "MD020", "no-missing-space-closed-atx" ],
|
|
10
12
|
"description": "No space inside hashes on closed atx style heading",
|
|
11
13
|
"tags": [ "headings", "atx_closed", "spaces" ],
|
|
14
|
+
"parser": "none",
|
|
12
15
|
"function": function MD020(params, onError) {
|
|
13
16
|
forEachLine(lineMetadata(), (line, lineIndex, inCode) => {
|
|
14
17
|
if (!inCode) {
|
package/lib/md021.js
CHANGED
|
@@ -7,10 +7,13 @@ const { addErrorContext, filterTokens, headingStyleFor } =
|
|
|
7
7
|
|
|
8
8
|
const closedAtxRe = /^(#+)([ \t]+)([^ \t]|[^ \t].*[^ \t])([ \t]+)(#+)(\s*)$/;
|
|
9
9
|
|
|
10
|
+
// eslint-disable-next-line jsdoc/valid-types
|
|
11
|
+
/** @type import("./markdownlint").Rule */
|
|
10
12
|
module.exports = {
|
|
11
13
|
"names": [ "MD021", "no-multiple-space-closed-atx" ],
|
|
12
14
|
"description": "Multiple spaces inside hashes on closed atx style heading",
|
|
13
15
|
"tags": [ "headings", "atx_closed", "spaces" ],
|
|
16
|
+
"parser": "markdownit",
|
|
14
17
|
"function": function MD021(params, onError) {
|
|
15
18
|
filterTokens(params, "heading_open", (token) => {
|
|
16
19
|
if (headingStyleFor(token) === "atx_closed") {
|