markdownlint 0.24.0 → 0.25.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/CONTRIBUTING.md +13 -3
- package/README.md +17 -7
- package/demo/markdownlint-browser.js +584 -367
- package/doc/CustomRules.md +15 -4
- package/doc/Rules.md +86 -13
- package/helpers/helpers.js +168 -50
- package/helpers/package.json +1 -1
- package/lib/cache.js +9 -9
- package/lib/constants.js +7 -0
- package/lib/markdownlint.d.ts +6 -2
- package/lib/markdownlint.js +216 -213
- package/lib/md007.js +4 -2
- package/lib/md010.js +21 -16
- package/lib/md011.js +2 -2
- package/lib/md033.js +12 -8
- package/lib/md035.js +4 -4
- package/lib/md037.js +5 -3
- package/lib/md039.js +2 -1
- package/lib/md043.js +0 -1
- package/lib/md044.js +2 -2
- package/lib/md049.js +45 -0
- package/lib/md050.js +45 -0
- package/lib/rules.js +4 -4
- package/package.json +25 -23
- package/schema/.markdownlint.jsonc +15 -1
- package/schema/.markdownlint.yaml +12 -0
- package/schema/markdownlint-config-schema.json +95 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! markdownlint 0.
|
|
1
|
+
/*! markdownlint 0.25.0 https://github.com/DavidAnson/markdownlint @license MIT */
|
|
2
2
|
var markdownlint;
|
|
3
3
|
/******/ (() => { // webpackBootstrap
|
|
4
4
|
/******/ var __webpack_modules__ = ({
|
|
@@ -25,12 +25,11 @@ module.exports = webpackEmptyContext;
|
|
|
25
25
|
/*!*****************************!*\
|
|
26
26
|
!*** ../helpers/helpers.js ***!
|
|
27
27
|
\*****************************/
|
|
28
|
-
/***/ ((module
|
|
28
|
+
/***/ ((module) => {
|
|
29
29
|
|
|
30
30
|
"use strict";
|
|
31
31
|
// @ts-check
|
|
32
32
|
|
|
33
|
-
var os = __webpack_require__(/*! os */ "?591e");
|
|
34
33
|
// Regular expression for matching common newline characters
|
|
35
34
|
// See NEWLINES_RE in markdown-it/lib/rules_core/normalize.js
|
|
36
35
|
var newLineRe = /\r\n?|\n/g;
|
|
@@ -77,12 +76,18 @@ module.exports.isObject = function isObject(obj) {
|
|
|
77
76
|
return (obj !== null) && (typeof obj === "object") && !Array.isArray(obj);
|
|
78
77
|
};
|
|
79
78
|
// Returns true iff the input line is blank (no content)
|
|
80
|
-
// Example: Contains nothing, whitespace, or
|
|
81
|
-
var blankLineRe = />|(?:<!--.*?-->)/g;
|
|
79
|
+
// Example: Contains nothing, whitespace, or comment (unclosed start/end okay)
|
|
82
80
|
module.exports.isBlankLine = function isBlankLine(line) {
|
|
83
81
|
// Call to String.replace follows best practices and is not a security check
|
|
84
82
|
// False-positive for js/incomplete-multi-character-sanitization
|
|
85
|
-
return !line ||
|
|
83
|
+
return (!line ||
|
|
84
|
+
!line.trim() ||
|
|
85
|
+
!line
|
|
86
|
+
.replace(/<!--.*?-->/g, "")
|
|
87
|
+
.replace(/<!--.*$/g, "")
|
|
88
|
+
.replace(/^.*-->/g, "")
|
|
89
|
+
.replace(/>/g, "")
|
|
90
|
+
.trim());
|
|
86
91
|
};
|
|
87
92
|
/**
|
|
88
93
|
* Compare function for Array.prototype.sort for ascending order of numbers.
|
|
@@ -190,6 +195,21 @@ module.exports.fencedCodeBlockStyleFor =
|
|
|
190
195
|
return "backtick";
|
|
191
196
|
}
|
|
192
197
|
};
|
|
198
|
+
/**
|
|
199
|
+
* Return the string representation of a emphasis or strong markup character.
|
|
200
|
+
*
|
|
201
|
+
* @param {string} markup Emphasis or strong string.
|
|
202
|
+
* @returns {string} String representation.
|
|
203
|
+
*/
|
|
204
|
+
module.exports.emphasisOrStrongStyleFor =
|
|
205
|
+
function emphasisOrStrongStyleFor(markup) {
|
|
206
|
+
switch (markup[0]) {
|
|
207
|
+
case "*":
|
|
208
|
+
return "asterisk";
|
|
209
|
+
default:
|
|
210
|
+
return "underscore";
|
|
211
|
+
}
|
|
212
|
+
};
|
|
193
213
|
/**
|
|
194
214
|
* Return the number of characters of indent for a token.
|
|
195
215
|
*
|
|
@@ -251,10 +271,11 @@ module.exports.filterTokens = filterTokens;
|
|
|
251
271
|
* @returns {boolean} True iff token is a math block.
|
|
252
272
|
*/
|
|
253
273
|
function isMathBlock(token) {
|
|
254
|
-
return ((token.tag === "math") &&
|
|
274
|
+
return (((token.tag === "$$") || (token.tag === "math")) &&
|
|
255
275
|
token.type.startsWith("math_block") &&
|
|
256
276
|
!token.type.endsWith("_end"));
|
|
257
277
|
}
|
|
278
|
+
module.exports.isMathBlock = isMathBlock;
|
|
258
279
|
// Get line metadata array
|
|
259
280
|
module.exports.getLineMetadata = function getLineMetadata(params) {
|
|
260
281
|
var lineMetadata = params.lines.map(function (line, index) { return [line, index, false, 0, false, false, false, false]; });
|
|
@@ -292,14 +313,20 @@ module.exports.getLineMetadata = function getLineMetadata(params) {
|
|
|
292
313
|
});
|
|
293
314
|
return lineMetadata;
|
|
294
315
|
};
|
|
295
|
-
|
|
296
|
-
|
|
316
|
+
/**
|
|
317
|
+
* Calls the provided function for each line.
|
|
318
|
+
*
|
|
319
|
+
* @param {Object} lineMetadata Line metadata object.
|
|
320
|
+
* @param {Function} handler Function taking (line, lineIndex, inCode, onFence,
|
|
321
|
+
* inTable, inItem, inBreak, inMath).
|
|
322
|
+
* @returns {void}
|
|
323
|
+
*/
|
|
324
|
+
function forEachLine(lineMetadata, handler) {
|
|
297
325
|
lineMetadata.forEach(function forMetadata(metadata) {
|
|
298
|
-
// Parameters:
|
|
299
|
-
// line, lineIndex, inCode, onFence, inTable, inItem, inBreak, inMath
|
|
300
326
|
handler.apply(void 0, metadata);
|
|
301
327
|
});
|
|
302
|
-
}
|
|
328
|
+
}
|
|
329
|
+
module.exports.forEachLine = forEachLine;
|
|
303
330
|
// Returns (nested) lists as a flat array (in order)
|
|
304
331
|
module.exports.flattenLists = function flattenLists(tokens) {
|
|
305
332
|
var flattenedLists = [];
|
|
@@ -309,10 +336,6 @@ module.exports.flattenLists = function flattenLists(tokens) {
|
|
|
309
336
|
var nestingStack = [];
|
|
310
337
|
var lastWithMap = { "map": [0, 1] };
|
|
311
338
|
tokens.forEach(function (token) {
|
|
312
|
-
if (isMathBlock(token) && token.map[1]) {
|
|
313
|
-
// markdown-it-texmath plugin does not account for math_block_end
|
|
314
|
-
token.map[1]++;
|
|
315
|
-
}
|
|
316
339
|
if ((token.type === "bullet_list_open") ||
|
|
317
340
|
(token.type === "ordered_list_open")) {
|
|
318
341
|
// Save current context and start a new one
|
|
@@ -388,7 +411,8 @@ module.exports.forEachHeading = function forEachHeading(params, handler) {
|
|
|
388
411
|
* Calls the provided function for each inline code span's content.
|
|
389
412
|
*
|
|
390
413
|
* @param {string} input Markdown content.
|
|
391
|
-
* @param {Function} handler Callback function
|
|
414
|
+
* @param {Function} handler Callback function taking (code, lineIndex,
|
|
415
|
+
* columnIndex, ticks).
|
|
392
416
|
* @returns {void}
|
|
393
417
|
*/
|
|
394
418
|
function forEachInlineCodeSpan(input, handler) {
|
|
@@ -518,19 +542,35 @@ module.exports.addErrorContext = function addErrorContext(onError, lineNumber, c
|
|
|
518
542
|
addError(onError, lineNumber, null, context, range, fixInfo);
|
|
519
543
|
};
|
|
520
544
|
/**
|
|
521
|
-
* Returns an array of code span ranges.
|
|
545
|
+
* Returns an array of code block and span content ranges.
|
|
522
546
|
*
|
|
523
|
-
* @param {
|
|
524
|
-
* @
|
|
547
|
+
* @param {Object} params RuleParams instance.
|
|
548
|
+
* @param {Object} lineMetadata Line metadata object.
|
|
549
|
+
* @returns {number[][]} Array of ranges (lineIndex, columnIndex, length).
|
|
525
550
|
*/
|
|
526
|
-
module.exports.
|
|
551
|
+
module.exports.codeBlockAndSpanRanges = function (params, lineMetadata) {
|
|
527
552
|
var exclusions = [];
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
553
|
+
// Add code block ranges (excludes fences)
|
|
554
|
+
forEachLine(lineMetadata, function (line, lineIndex, inCode, onFence) {
|
|
555
|
+
if (inCode && !onFence) {
|
|
556
|
+
exclusions.push([lineIndex, 0, line.length]);
|
|
557
|
+
}
|
|
558
|
+
});
|
|
559
|
+
// Add code span ranges (excludes ticks)
|
|
560
|
+
filterTokens(params, "inline", function (token) {
|
|
561
|
+
if (token.children.some(function (child) { return child.type === "code_inline"; })) {
|
|
562
|
+
var tokenLines = params.lines.slice(token.map[0], token.map[1]);
|
|
563
|
+
forEachInlineCodeSpan(tokenLines.join("\n"), function (code, lineIndex, columnIndex) {
|
|
564
|
+
var codeLines = code.split(newLineRe);
|
|
565
|
+
for (var _i = 0, _a = codeLines.entries(); _i < _a.length; _i++) {
|
|
566
|
+
var _b = _a[_i], i = _b[0], line = _b[1];
|
|
567
|
+
exclusions.push([
|
|
568
|
+
token.lineNumber - 1 + lineIndex + i,
|
|
569
|
+
i ? 0 : columnIndex,
|
|
570
|
+
line.length
|
|
571
|
+
]);
|
|
572
|
+
}
|
|
573
|
+
});
|
|
534
574
|
}
|
|
535
575
|
});
|
|
536
576
|
return exclusions;
|
|
@@ -553,8 +593,8 @@ module.exports.rangeFromRegExp = function rangeFromRegExp(line, regexp) {
|
|
|
553
593
|
var match = line.match(regexp);
|
|
554
594
|
if (match) {
|
|
555
595
|
var column = match.index + 1;
|
|
556
|
-
var
|
|
557
|
-
range = [column,
|
|
596
|
+
var length = match[0].length;
|
|
597
|
+
range = [column, length];
|
|
558
598
|
}
|
|
559
599
|
return range;
|
|
560
600
|
};
|
|
@@ -575,6 +615,18 @@ module.exports.frontMatterHasTitle =
|
|
|
575
615
|
function emphasisMarkersInContent(params) {
|
|
576
616
|
var lines = params.lines;
|
|
577
617
|
var byLine = new Array(lines.length);
|
|
618
|
+
// Search links
|
|
619
|
+
lines.forEach(function (tokenLine, tokenLineIndex) {
|
|
620
|
+
var inLine = [];
|
|
621
|
+
var linkMatch = null;
|
|
622
|
+
while ((linkMatch = linkRe.exec(tokenLine))) {
|
|
623
|
+
var markerMatch = null;
|
|
624
|
+
while ((markerMatch = emphasisMarkersRe.exec(linkMatch[0]))) {
|
|
625
|
+
inLine.push(linkMatch.index + markerMatch.index);
|
|
626
|
+
}
|
|
627
|
+
}
|
|
628
|
+
byLine[tokenLineIndex] = inLine;
|
|
629
|
+
});
|
|
578
630
|
// Search code spans
|
|
579
631
|
filterTokens(params, "inline", function (token) {
|
|
580
632
|
var children = token.children, lineNumber = token.lineNumber, map = token.map;
|
|
@@ -583,30 +635,18 @@ function emphasisMarkersInContent(params) {
|
|
|
583
635
|
forEachInlineCodeSpan(tokenLines.join("\n"), function (code, lineIndex, column, tickCount) {
|
|
584
636
|
var codeLines = code.split(newLineRe);
|
|
585
637
|
codeLines.forEach(function (codeLine, codeLineIndex) {
|
|
638
|
+
var byLineIndex = lineNumber - 1 + lineIndex + codeLineIndex;
|
|
639
|
+
var inLine = byLine[byLineIndex];
|
|
640
|
+
var codeLineOffset = codeLineIndex ? 0 : column - 1 + tickCount;
|
|
586
641
|
var match = null;
|
|
587
642
|
while ((match = emphasisMarkersRe.exec(codeLine))) {
|
|
588
|
-
var byLineIndex = lineNumber - 1 + lineIndex + codeLineIndex;
|
|
589
|
-
var inLine = byLine[byLineIndex] || [];
|
|
590
|
-
var codeLineOffset = codeLineIndex ? 0 : column - 1 + tickCount;
|
|
591
643
|
inLine.push(codeLineOffset + match.index);
|
|
592
|
-
byLine[byLineIndex] = inLine;
|
|
593
644
|
}
|
|
645
|
+
byLine[byLineIndex] = inLine;
|
|
594
646
|
});
|
|
595
647
|
});
|
|
596
648
|
}
|
|
597
649
|
});
|
|
598
|
-
// Search links
|
|
599
|
-
lines.forEach(function (tokenLine, tokenLineIndex) {
|
|
600
|
-
var linkMatch = null;
|
|
601
|
-
while ((linkMatch = linkRe.exec(tokenLine))) {
|
|
602
|
-
var markerMatch = null;
|
|
603
|
-
while ((markerMatch = emphasisMarkersRe.exec(linkMatch[0]))) {
|
|
604
|
-
var inLine = byLine[tokenLineIndex] || [];
|
|
605
|
-
inLine.push(linkMatch.index + markerMatch.index);
|
|
606
|
-
byLine[tokenLineIndex] = inLine;
|
|
607
|
-
}
|
|
608
|
-
}
|
|
609
|
-
});
|
|
610
650
|
return byLine;
|
|
611
651
|
}
|
|
612
652
|
module.exports.emphasisMarkersInContent = emphasisMarkersInContent;
|
|
@@ -614,9 +654,10 @@ module.exports.emphasisMarkersInContent = emphasisMarkersInContent;
|
|
|
614
654
|
* Gets the most common line ending, falling back to the platform default.
|
|
615
655
|
*
|
|
616
656
|
* @param {string} input Markdown content to analyze.
|
|
657
|
+
* @param {string} [platform] Platform identifier (process.platform).
|
|
617
658
|
* @returns {string} Preferred line ending.
|
|
618
659
|
*/
|
|
619
|
-
function getPreferredLineEnding(input) {
|
|
660
|
+
function getPreferredLineEnding(input, platform) {
|
|
620
661
|
var cr = 0;
|
|
621
662
|
var lf = 0;
|
|
622
663
|
var crlf = 0;
|
|
@@ -637,7 +678,8 @@ function getPreferredLineEnding(input) {
|
|
|
637
678
|
});
|
|
638
679
|
var preferredLineEnding = null;
|
|
639
680
|
if (!cr && !lf && !crlf) {
|
|
640
|
-
preferredLineEnding =
|
|
681
|
+
preferredLineEnding =
|
|
682
|
+
((platform || process.platform) === "win32") ? "\r\n" : "\n";
|
|
641
683
|
}
|
|
642
684
|
else if ((lf >= crlf) && (lf >= cr)) {
|
|
643
685
|
preferredLineEnding = "\n";
|
|
@@ -745,6 +787,79 @@ module.exports.applyFixes = function applyFixes(input, errors) {
|
|
|
745
787
|
// Return corrected input
|
|
746
788
|
return lines.filter(function (line) { return line !== null; }).join(lineEnding);
|
|
747
789
|
};
|
|
790
|
+
/**
|
|
791
|
+
* Gets the range and fixInfo values for reporting an error if the expected
|
|
792
|
+
* text is found on the specified line.
|
|
793
|
+
*
|
|
794
|
+
* @param {string[]} lines Lines of Markdown content.
|
|
795
|
+
* @param {number} lineIndex Line index to check.
|
|
796
|
+
* @param {string} search Text to search for.
|
|
797
|
+
* @param {string} replace Text to replace with.
|
|
798
|
+
* @returns {Object} Range and fixInfo wrapper.
|
|
799
|
+
*/
|
|
800
|
+
function getRangeAndFixInfoIfFound(lines, lineIndex, search, replace) {
|
|
801
|
+
var range = null;
|
|
802
|
+
var fixInfo = null;
|
|
803
|
+
var searchIndex = lines[lineIndex].indexOf(search);
|
|
804
|
+
if (searchIndex !== -1) {
|
|
805
|
+
var column = searchIndex + 1;
|
|
806
|
+
var length = search.length;
|
|
807
|
+
range = [column, length];
|
|
808
|
+
fixInfo = {
|
|
809
|
+
"editColumn": column,
|
|
810
|
+
"deleteCount": length,
|
|
811
|
+
"insertText": replace
|
|
812
|
+
};
|
|
813
|
+
}
|
|
814
|
+
return {
|
|
815
|
+
range: range,
|
|
816
|
+
fixInfo: fixInfo
|
|
817
|
+
};
|
|
818
|
+
}
|
|
819
|
+
module.exports.getRangeAndFixInfoIfFound = getRangeAndFixInfoIfFound;
|
|
820
|
+
/**
|
|
821
|
+
* Gets the next (subsequent) child token if it is of the expected type.
|
|
822
|
+
*
|
|
823
|
+
* @param {Object} parentToken Parent token.
|
|
824
|
+
* @param {Object} childToken Child token basis.
|
|
825
|
+
* @param {string} nextType Token type of next token.
|
|
826
|
+
* @param {string} nextNextType Token type of next-next token.
|
|
827
|
+
* @returns {Object} Next token.
|
|
828
|
+
*/
|
|
829
|
+
function getNextChildToken(parentToken, childToken, nextType, nextNextType) {
|
|
830
|
+
var children = parentToken.children;
|
|
831
|
+
var index = children.indexOf(childToken);
|
|
832
|
+
if ((index !== -1) &&
|
|
833
|
+
(children.length > index + 2) &&
|
|
834
|
+
(children[index + 1].type === nextType) &&
|
|
835
|
+
(children[index + 2].type === nextNextType)) {
|
|
836
|
+
return children[index + 1];
|
|
837
|
+
}
|
|
838
|
+
return null;
|
|
839
|
+
}
|
|
840
|
+
module.exports.getNextChildToken = getNextChildToken;
|
|
841
|
+
/**
|
|
842
|
+
* Calls Object.freeze() on an object and its children.
|
|
843
|
+
*
|
|
844
|
+
* @param {Object} obj Object to deep freeze.
|
|
845
|
+
* @returns {Object} Object passed to the function.
|
|
846
|
+
*/
|
|
847
|
+
function deepFreeze(obj) {
|
|
848
|
+
var pending = [obj];
|
|
849
|
+
var current = null;
|
|
850
|
+
while ((current = pending.shift())) {
|
|
851
|
+
Object.freeze(current);
|
|
852
|
+
for (var _i = 0, _a = Object.getOwnPropertyNames(current); _i < _a.length; _i++) {
|
|
853
|
+
var name = _a[_i];
|
|
854
|
+
var value = current[name];
|
|
855
|
+
if (value && (typeof value === "object")) {
|
|
856
|
+
pending.push(value);
|
|
857
|
+
}
|
|
858
|
+
}
|
|
859
|
+
}
|
|
860
|
+
return obj;
|
|
861
|
+
}
|
|
862
|
+
module.exports.deepFreeze = deepFreeze;
|
|
748
863
|
|
|
749
864
|
|
|
750
865
|
/***/ }),
|
|
@@ -758,6 +873,13 @@ module.exports.applyFixes = function applyFixes(input, errors) {
|
|
|
758
873
|
"use strict";
|
|
759
874
|
// @ts-check
|
|
760
875
|
|
|
876
|
+
var codeBlockAndSpanRanges = null;
|
|
877
|
+
module.exports.codeBlockAndSpanRanges = function (value) {
|
|
878
|
+
if (value) {
|
|
879
|
+
codeBlockAndSpanRanges = value;
|
|
880
|
+
}
|
|
881
|
+
return codeBlockAndSpanRanges;
|
|
882
|
+
};
|
|
761
883
|
var flattenedLists = null;
|
|
762
884
|
module.exports.flattenedLists = function (value) {
|
|
763
885
|
if (value) {
|
|
@@ -765,13 +887,6 @@ module.exports.flattenedLists = function (value) {
|
|
|
765
887
|
}
|
|
766
888
|
return flattenedLists;
|
|
767
889
|
};
|
|
768
|
-
var inlineCodeSpanRanges = null;
|
|
769
|
-
module.exports.inlineCodeSpanRanges = function (value) {
|
|
770
|
-
if (value) {
|
|
771
|
-
inlineCodeSpanRanges = value;
|
|
772
|
-
}
|
|
773
|
-
return inlineCodeSpanRanges;
|
|
774
|
-
};
|
|
775
890
|
var lineMetadata = null;
|
|
776
891
|
module.exports.lineMetadata = function (value) {
|
|
777
892
|
if (value) {
|
|
@@ -780,12 +895,28 @@ module.exports.lineMetadata = function (value) {
|
|
|
780
895
|
return lineMetadata;
|
|
781
896
|
};
|
|
782
897
|
module.exports.clear = function () {
|
|
898
|
+
codeBlockAndSpanRanges = null;
|
|
783
899
|
flattenedLists = null;
|
|
784
|
-
inlineCodeSpanRanges = null;
|
|
785
900
|
lineMetadata = null;
|
|
786
901
|
};
|
|
787
902
|
|
|
788
903
|
|
|
904
|
+
/***/ }),
|
|
905
|
+
|
|
906
|
+
/***/ "../lib/constants.js":
|
|
907
|
+
/*!***************************!*\
|
|
908
|
+
!*** ../lib/constants.js ***!
|
|
909
|
+
\***************************/
|
|
910
|
+
/***/ ((module) => {
|
|
911
|
+
|
|
912
|
+
"use strict";
|
|
913
|
+
// @ts-check
|
|
914
|
+
|
|
915
|
+
module.exports.deprecatedRuleNames = ["MD002", "MD006"];
|
|
916
|
+
module.exports.homepage = "https://github.com/DavidAnson/markdownlint";
|
|
917
|
+
module.exports.version = "0.25.0";
|
|
918
|
+
|
|
919
|
+
|
|
789
920
|
/***/ }),
|
|
790
921
|
|
|
791
922
|
/***/ "../lib/markdownlint.js":
|
|
@@ -808,14 +939,19 @@ var __assign = (this && this.__assign) || function () {
|
|
|
808
939
|
};
|
|
809
940
|
return __assign.apply(this, arguments);
|
|
810
941
|
};
|
|
811
|
-
var __spreadArray = (this && this.__spreadArray) || function (to, from) {
|
|
812
|
-
for (var i = 0,
|
|
813
|
-
|
|
814
|
-
|
|
942
|
+
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
943
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
944
|
+
if (ar || !(i in from)) {
|
|
945
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
946
|
+
ar[i] = from[i];
|
|
947
|
+
}
|
|
948
|
+
}
|
|
949
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
815
950
|
};
|
|
816
951
|
var path = __webpack_require__(/*! path */ "?b85c");
|
|
817
|
-
var promisify = __webpack_require__(/*! util */ "?96a2").promisify;
|
|
952
|
+
var promisify = (__webpack_require__(/*! util */ "?96a2").promisify);
|
|
818
953
|
var markdownIt = __webpack_require__(/*! markdown-it */ "markdown-it");
|
|
954
|
+
var deprecatedRuleNames = (__webpack_require__(/*! ./constants */ "../lib/constants.js").deprecatedRuleNames);
|
|
819
955
|
var rules = __webpack_require__(/*! ./rules */ "../lib/rules.js");
|
|
820
956
|
var helpers = __webpack_require__(/*! ../helpers */ "../helpers/helpers.js");
|
|
821
957
|
var cache = __webpack_require__(/*! ./cache */ "../lib/cache.js");
|
|
@@ -823,14 +959,14 @@ var cache = __webpack_require__(/*! ./cache */ "../lib/cache.js");
|
|
|
823
959
|
// eslint-disable-next-line camelcase, max-len, no-inline-comments, no-undef
|
|
824
960
|
var dynamicRequire = (typeof require === "undefined") ? __webpack_require__("../lib sync recursive") : /* c8 ignore next */ require;
|
|
825
961
|
// Capture native require implementation for dynamic loading of modules
|
|
826
|
-
var deprecatedRuleNames = ["MD002", "MD006"];
|
|
827
962
|
/**
|
|
828
963
|
* Validate the list of rules for structure and reuse.
|
|
829
964
|
*
|
|
830
965
|
* @param {Rule[]} ruleList List of rules.
|
|
966
|
+
* @param {boolean} synchronous Whether to execute synchronously.
|
|
831
967
|
* @returns {string} Error message if validation fails.
|
|
832
968
|
*/
|
|
833
|
-
function validateRuleList(ruleList) {
|
|
969
|
+
function validateRuleList(ruleList, synchronous) {
|
|
834
970
|
var result = null;
|
|
835
971
|
if (ruleList.length === rules.length) {
|
|
836
972
|
// No need to validate if only using built-in rules
|
|
@@ -867,6 +1003,15 @@ function validateRuleList(ruleList) {
|
|
|
867
1003
|
(Object.getPrototypeOf(rule.information) !== URL.prototype)) {
|
|
868
1004
|
result = newError("information");
|
|
869
1005
|
}
|
|
1006
|
+
if (!result &&
|
|
1007
|
+
(rule.asynchronous !== undefined) &&
|
|
1008
|
+
(typeof rule.asynchronous !== "boolean")) {
|
|
1009
|
+
result = newError("asynchronous");
|
|
1010
|
+
}
|
|
1011
|
+
if (!result && rule.asynchronous && synchronous) {
|
|
1012
|
+
result = new Error("Custom rule " + rule.names.join("/") + " at index " + customIndex +
|
|
1013
|
+
" is asynchronous and can not be used in a synchronous context.");
|
|
1014
|
+
}
|
|
870
1015
|
if (!result) {
|
|
871
1016
|
rule.names.forEach(function forName(name) {
|
|
872
1017
|
var nameUpper = name.toUpperCase();
|
|
@@ -983,23 +1128,22 @@ function removeFrontMatter(content, frontMatter) {
|
|
|
983
1128
|
* @returns {void}
|
|
984
1129
|
*/
|
|
985
1130
|
function annotateTokens(tokens, lines) {
|
|
986
|
-
var
|
|
1131
|
+
var trMap = null;
|
|
987
1132
|
tokens.forEach(function forToken(token) {
|
|
988
|
-
//
|
|
989
|
-
if (
|
|
990
|
-
|
|
991
|
-
tableMap = __spreadArray([], token.map);
|
|
1133
|
+
// Provide missing maps for table content
|
|
1134
|
+
if (token.type === "tr_open") {
|
|
1135
|
+
trMap = token.map;
|
|
992
1136
|
}
|
|
993
|
-
else if (
|
|
994
|
-
|
|
995
|
-
tableMap[0]++;
|
|
1137
|
+
else if (token.type === "tr_close") {
|
|
1138
|
+
trMap = null;
|
|
996
1139
|
}
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
tableMap = null;
|
|
1140
|
+
if (!token.map && trMap) {
|
|
1141
|
+
token.map = __spreadArray([], trMap, true);
|
|
1000
1142
|
}
|
|
1001
|
-
|
|
1002
|
-
|
|
1143
|
+
// Adjust maps for math blocks
|
|
1144
|
+
if (helpers.isMathBlock(token) && token.map[1]) {
|
|
1145
|
+
// markdown-it-texmath plugin does not account for math_block_end
|
|
1146
|
+
token.map[1]++;
|
|
1003
1147
|
}
|
|
1004
1148
|
// Update token metadata
|
|
1005
1149
|
if (token.map) {
|
|
@@ -1120,8 +1264,7 @@ function getEnabledRulesPerLineNumber(ruleList, lines, frontMatterLines, noInlin
|
|
|
1120
1264
|
var enabledRulesPerLineNumber = new Array(1 + frontMatterLines.length);
|
|
1121
1265
|
// Helper functions
|
|
1122
1266
|
// eslint-disable-next-line jsdoc/require-jsdoc
|
|
1123
|
-
function handleInlineConfig(
|
|
1124
|
-
var input = perLine ? lines : [lines.join("\n")];
|
|
1267
|
+
function handleInlineConfig(input, forEachMatch, forEachLine) {
|
|
1125
1268
|
input.forEach(function (line, lineIndex) {
|
|
1126
1269
|
if (!noInlineConfig) {
|
|
1127
1270
|
var match = null;
|
|
@@ -1150,6 +1293,7 @@ function getEnabledRulesPerLineNumber(ruleList, lines, frontMatterLines, noInlin
|
|
|
1150
1293
|
}
|
|
1151
1294
|
// eslint-disable-next-line jsdoc/require-jsdoc
|
|
1152
1295
|
function applyEnableDisable(action, parameter, state) {
|
|
1296
|
+
state = __assign({}, state);
|
|
1153
1297
|
var enabled = (action.startsWith("ENABLE"));
|
|
1154
1298
|
var items = parameter ?
|
|
1155
1299
|
parameter.trim().toUpperCase().split(/\s+/) :
|
|
@@ -1159,38 +1303,40 @@ function getEnabledRulesPerLineNumber(ruleList, lines, frontMatterLines, noInlin
|
|
|
1159
1303
|
state[ruleName] = enabled;
|
|
1160
1304
|
});
|
|
1161
1305
|
});
|
|
1306
|
+
return state;
|
|
1162
1307
|
}
|
|
1163
1308
|
// eslint-disable-next-line jsdoc/require-jsdoc
|
|
1164
1309
|
function enableDisableFile(action, parameter) {
|
|
1165
1310
|
if ((action === "ENABLE-FILE") || (action === "DISABLE-FILE")) {
|
|
1166
|
-
applyEnableDisable(action, parameter, enabledRules);
|
|
1311
|
+
enabledRules = applyEnableDisable(action, parameter, enabledRules);
|
|
1167
1312
|
}
|
|
1168
1313
|
}
|
|
1169
1314
|
// eslint-disable-next-line jsdoc/require-jsdoc
|
|
1170
1315
|
function captureRestoreEnableDisable(action, parameter) {
|
|
1171
1316
|
if (action === "CAPTURE") {
|
|
1172
|
-
capturedRules =
|
|
1317
|
+
capturedRules = enabledRules;
|
|
1173
1318
|
}
|
|
1174
1319
|
else if (action === "RESTORE") {
|
|
1175
|
-
enabledRules =
|
|
1320
|
+
enabledRules = capturedRules;
|
|
1176
1321
|
}
|
|
1177
1322
|
else if ((action === "ENABLE") || (action === "DISABLE")) {
|
|
1178
|
-
enabledRules =
|
|
1179
|
-
applyEnableDisable(action, parameter, enabledRules);
|
|
1323
|
+
enabledRules = applyEnableDisable(action, parameter, enabledRules);
|
|
1180
1324
|
}
|
|
1181
1325
|
}
|
|
1182
1326
|
// eslint-disable-next-line jsdoc/require-jsdoc
|
|
1183
1327
|
function updateLineState() {
|
|
1184
|
-
enabledRulesPerLineNumber.push(
|
|
1328
|
+
enabledRulesPerLineNumber.push(enabledRules);
|
|
1185
1329
|
}
|
|
1186
1330
|
// eslint-disable-next-line jsdoc/require-jsdoc
|
|
1187
1331
|
function disableNextLine(action, parameter, lineNumber) {
|
|
1188
1332
|
if (action === "DISABLE-NEXT-LINE") {
|
|
1189
|
-
|
|
1333
|
+
var nextLineNumber = frontMatterLines.length + lineNumber + 1;
|
|
1334
|
+
enabledRulesPerLineNumber[nextLineNumber] =
|
|
1335
|
+
applyEnableDisable(action, parameter, enabledRulesPerLineNumber[nextLineNumber] || {});
|
|
1190
1336
|
}
|
|
1191
1337
|
}
|
|
1192
1338
|
// Handle inline comments
|
|
1193
|
-
handleInlineConfig(
|
|
1339
|
+
handleInlineConfig([lines.join("\n")], configureFile);
|
|
1194
1340
|
var effectiveConfig = getEffectiveConfig(ruleList, config, aliasToRuleNames);
|
|
1195
1341
|
ruleList.forEach(function (rule) {
|
|
1196
1342
|
var ruleName = rule.names[0].toUpperCase();
|
|
@@ -1198,44 +1344,15 @@ function getEnabledRulesPerLineNumber(ruleList, lines, frontMatterLines, noInlin
|
|
|
1198
1344
|
enabledRules[ruleName] = !!effectiveConfig[ruleName];
|
|
1199
1345
|
});
|
|
1200
1346
|
capturedRules = enabledRules;
|
|
1201
|
-
handleInlineConfig(
|
|
1202
|
-
handleInlineConfig(
|
|
1203
|
-
handleInlineConfig(
|
|
1347
|
+
handleInlineConfig(lines, enableDisableFile);
|
|
1348
|
+
handleInlineConfig(lines, captureRestoreEnableDisable, updateLineState);
|
|
1349
|
+
handleInlineConfig(lines, disableNextLine);
|
|
1204
1350
|
// Return results
|
|
1205
1351
|
return {
|
|
1206
1352
|
effectiveConfig: effectiveConfig,
|
|
1207
1353
|
enabledRulesPerLineNumber: enabledRulesPerLineNumber
|
|
1208
1354
|
};
|
|
1209
1355
|
}
|
|
1210
|
-
/**
|
|
1211
|
-
* Compare function for Array.prototype.sort for ascending order of errors.
|
|
1212
|
-
*
|
|
1213
|
-
* @param {LintError} a First error.
|
|
1214
|
-
* @param {LintError} b Second error.
|
|
1215
|
-
* @returns {number} Positive value if a>b, negative value if b<a, 0 otherwise.
|
|
1216
|
-
*/
|
|
1217
|
-
function lineNumberComparison(a, b) {
|
|
1218
|
-
return a.lineNumber - b.lineNumber;
|
|
1219
|
-
}
|
|
1220
|
-
/**
|
|
1221
|
-
* Filter function to include everything.
|
|
1222
|
-
*
|
|
1223
|
-
* @returns {boolean} True.
|
|
1224
|
-
*/
|
|
1225
|
-
function filterAllValues() {
|
|
1226
|
-
return true;
|
|
1227
|
-
}
|
|
1228
|
-
/**
|
|
1229
|
-
* Function to return unique values from a sorted errors array.
|
|
1230
|
-
*
|
|
1231
|
-
* @param {LintError} value Error instance.
|
|
1232
|
-
* @param {number} index Index in array.
|
|
1233
|
-
* @param {LintError[]} array Array of errors.
|
|
1234
|
-
* @returns {boolean} Filter value.
|
|
1235
|
-
*/
|
|
1236
|
-
function uniqueFilterForSortedErrors(value, index, array) {
|
|
1237
|
-
return (index === 0) || (value.lineNumber > array[index - 1].lineNumber);
|
|
1238
|
-
}
|
|
1239
1356
|
/**
|
|
1240
1357
|
* Lints a string containing Markdown content.
|
|
1241
1358
|
*
|
|
@@ -1267,27 +1384,25 @@ function lintContent(ruleList, name, content, md, config, frontMatter, handleRul
|
|
|
1267
1384
|
var _a = getEnabledRulesPerLineNumber(ruleList, lines, frontMatterLines, noInlineConfig, config, aliasToRuleNames), effectiveConfig = _a.effectiveConfig, enabledRulesPerLineNumber = _a.enabledRulesPerLineNumber;
|
|
1268
1385
|
// Create parameters for rules
|
|
1269
1386
|
var params = {
|
|
1270
|
-
name: name,
|
|
1271
|
-
tokens: tokens,
|
|
1272
|
-
lines: lines,
|
|
1273
|
-
frontMatterLines: frontMatterLines
|
|
1387
|
+
"name": helpers.deepFreeze(name),
|
|
1388
|
+
"tokens": helpers.deepFreeze(tokens),
|
|
1389
|
+
"lines": helpers.deepFreeze(lines),
|
|
1390
|
+
"frontMatterLines": helpers.deepFreeze(frontMatterLines)
|
|
1274
1391
|
};
|
|
1275
1392
|
cache.lineMetadata(helpers.getLineMetadata(params));
|
|
1276
1393
|
cache.flattenedLists(helpers.flattenLists(params.tokens));
|
|
1277
|
-
cache.
|
|
1394
|
+
cache.codeBlockAndSpanRanges(helpers.codeBlockAndSpanRanges(params, cache.lineMetadata()));
|
|
1278
1395
|
// Function to run for each rule
|
|
1279
|
-
var
|
|
1396
|
+
var results = [];
|
|
1280
1397
|
// eslint-disable-next-line jsdoc/require-jsdoc
|
|
1281
1398
|
function forRule(rule) {
|
|
1282
1399
|
// Configure rule
|
|
1283
|
-
var
|
|
1284
|
-
var ruleName = ruleNameFriendly.toUpperCase();
|
|
1400
|
+
var ruleName = rule.names[0].toUpperCase();
|
|
1285
1401
|
params.config = effectiveConfig[ruleName];
|
|
1286
1402
|
// eslint-disable-next-line jsdoc/require-jsdoc
|
|
1287
1403
|
function throwError(property) {
|
|
1288
1404
|
throw new Error("Property '" + property + "' of onError parameter is incorrect.");
|
|
1289
1405
|
}
|
|
1290
|
-
var errors = [];
|
|
1291
1406
|
// eslint-disable-next-line jsdoc/require-jsdoc
|
|
1292
1407
|
function onError(errorInfo) {
|
|
1293
1408
|
if (!errorInfo ||
|
|
@@ -1296,6 +1411,10 @@ function lintContent(ruleList, name, content, md, config, frontMatter, handleRul
|
|
|
1296
1411
|
(errorInfo.lineNumber > lines.length)) {
|
|
1297
1412
|
throwError("lineNumber");
|
|
1298
1413
|
}
|
|
1414
|
+
var lineNumber = errorInfo.lineNumber + frontMatterLines.length;
|
|
1415
|
+
if (!enabledRulesPerLineNumber[lineNumber][ruleName]) {
|
|
1416
|
+
return;
|
|
1417
|
+
}
|
|
1299
1418
|
if (errorInfo.detail &&
|
|
1300
1419
|
!helpers.isString(errorInfo.detail)) {
|
|
1301
1420
|
throwError("detail");
|
|
@@ -1356,83 +1475,115 @@ function lintContent(ruleList, name, content, md, config, frontMatter, handleRul
|
|
|
1356
1475
|
cleanFixInfo.insertText = fixInfo.insertText;
|
|
1357
1476
|
}
|
|
1358
1477
|
}
|
|
1359
|
-
|
|
1360
|
-
|
|
1361
|
-
"
|
|
1362
|
-
"
|
|
1363
|
-
"
|
|
1478
|
+
results.push({
|
|
1479
|
+
lineNumber: lineNumber,
|
|
1480
|
+
"ruleName": rule.names[0],
|
|
1481
|
+
"ruleNames": rule.names,
|
|
1482
|
+
"ruleDescription": rule.description,
|
|
1483
|
+
"ruleInformation": rule.information ? rule.information.href : null,
|
|
1484
|
+
"errorDetail": errorInfo.detail || null,
|
|
1485
|
+
"errorContext": errorInfo.context || null,
|
|
1486
|
+
"errorRange": errorInfo.range ? __spreadArray([], errorInfo.range, true) : null,
|
|
1364
1487
|
"fixInfo": fixInfo ? cleanFixInfo : null
|
|
1365
1488
|
});
|
|
1366
1489
|
}
|
|
1367
|
-
// Call (possibly external) rule function
|
|
1368
|
-
|
|
1369
|
-
|
|
1370
|
-
|
|
1490
|
+
// Call (possibly external) rule function to report errors
|
|
1491
|
+
var catchCallsOnError = function (error) { return onError({
|
|
1492
|
+
"lineNumber": 1,
|
|
1493
|
+
"detail": "This rule threw an exception: ".concat(error.message || error)
|
|
1494
|
+
}); };
|
|
1495
|
+
var invokeRuleFunction = function () { return rule.function(params, onError); };
|
|
1496
|
+
if (rule.asynchronous) {
|
|
1497
|
+
// Asynchronous rule, ensure it returns a Promise
|
|
1498
|
+
var ruleFunctionPromise = Promise.resolve().then(invokeRuleFunction);
|
|
1499
|
+
return handleRuleFailures ?
|
|
1500
|
+
ruleFunctionPromise.catch(catchCallsOnError) :
|
|
1501
|
+
ruleFunctionPromise;
|
|
1502
|
+
}
|
|
1503
|
+
// Synchronous rule
|
|
1504
|
+
try {
|
|
1505
|
+
invokeRuleFunction();
|
|
1506
|
+
}
|
|
1507
|
+
catch (error) {
|
|
1508
|
+
if (handleRuleFailures) {
|
|
1509
|
+
catchCallsOnError(error);
|
|
1371
1510
|
}
|
|
1372
|
-
|
|
1373
|
-
|
|
1374
|
-
"lineNumber": 1,
|
|
1375
|
-
"detail": "This rule threw an exception: " + error.message
|
|
1376
|
-
});
|
|
1511
|
+
else {
|
|
1512
|
+
throw error;
|
|
1377
1513
|
}
|
|
1378
1514
|
}
|
|
1379
|
-
|
|
1380
|
-
|
|
1381
|
-
|
|
1382
|
-
|
|
1383
|
-
|
|
1384
|
-
|
|
1385
|
-
|
|
1386
|
-
|
|
1387
|
-
|
|
1388
|
-
|
|
1389
|
-
|
|
1390
|
-
|
|
1391
|
-
}
|
|
1392
|
-
|
|
1393
|
-
|
|
1394
|
-
|
|
1395
|
-
|
|
1396
|
-
|
|
1397
|
-
errorObject.lineNumber = error.lineNumber;
|
|
1398
|
-
if (resultVersion === 1) {
|
|
1399
|
-
errorObject.ruleName = ruleNameFriendly;
|
|
1400
|
-
errorObject.ruleAlias = rule.names[1] || rule.names[0];
|
|
1401
|
-
}
|
|
1402
|
-
else {
|
|
1403
|
-
errorObject.ruleNames = rule.names;
|
|
1404
|
-
}
|
|
1405
|
-
errorObject.ruleDescription = rule.description;
|
|
1406
|
-
errorObject.ruleInformation =
|
|
1407
|
-
rule.information ? rule.information.href : null;
|
|
1408
|
-
errorObject.errorDetail = error.detail;
|
|
1409
|
-
errorObject.errorContext = error.context;
|
|
1410
|
-
errorObject.errorRange = error.range;
|
|
1411
|
-
if (resultVersion === 3) {
|
|
1412
|
-
errorObject.fixInfo = error.fixInfo;
|
|
1413
|
-
}
|
|
1414
|
-
return errorObject;
|
|
1515
|
+
return null;
|
|
1516
|
+
}
|
|
1517
|
+
// eslint-disable-next-line jsdoc/require-jsdoc
|
|
1518
|
+
function formatResults() {
|
|
1519
|
+
// Sort results by rule name by line number
|
|
1520
|
+
results.sort(function (a, b) { return (a.ruleName.localeCompare(b.ruleName) ||
|
|
1521
|
+
a.lineNumber - b.lineNumber); });
|
|
1522
|
+
if (resultVersion < 3) {
|
|
1523
|
+
// Remove fixInfo and multiple errors for the same rule and line number
|
|
1524
|
+
var noPrevious_1 = {
|
|
1525
|
+
"ruleName": null,
|
|
1526
|
+
"lineNumber": -1
|
|
1527
|
+
};
|
|
1528
|
+
results = results.filter(function (error, index, array) {
|
|
1529
|
+
delete error.fixInfo;
|
|
1530
|
+
var previous = array[index - 1] || noPrevious_1;
|
|
1531
|
+
return ((error.ruleName !== previous.ruleName) ||
|
|
1532
|
+
(error.lineNumber !== previous.lineNumber));
|
|
1415
1533
|
});
|
|
1416
|
-
|
|
1417
|
-
|
|
1418
|
-
|
|
1419
|
-
|
|
1420
|
-
|
|
1421
|
-
|
|
1422
|
-
|
|
1534
|
+
}
|
|
1535
|
+
if (resultVersion === 0) {
|
|
1536
|
+
// Return a dictionary of rule->[line numbers]
|
|
1537
|
+
var dictionary = {};
|
|
1538
|
+
for (var _i = 0, results_1 = results; _i < results_1.length; _i++) {
|
|
1539
|
+
var error = results_1[_i];
|
|
1540
|
+
var ruleLines = dictionary[error.ruleName] || [];
|
|
1541
|
+
ruleLines.push(error.lineNumber);
|
|
1542
|
+
dictionary[error.ruleName] = ruleLines;
|
|
1543
|
+
}
|
|
1544
|
+
// @ts-ignore
|
|
1545
|
+
results = dictionary;
|
|
1546
|
+
}
|
|
1547
|
+
else if (resultVersion === 1) {
|
|
1548
|
+
// Use ruleAlias instead of ruleNames
|
|
1549
|
+
for (var _a = 0, results_2 = results; _a < results_2.length; _a++) {
|
|
1550
|
+
var error = results_2[_a];
|
|
1551
|
+
error.ruleAlias = error.ruleNames[1] || error.ruleName;
|
|
1552
|
+
delete error.ruleNames;
|
|
1553
|
+
}
|
|
1554
|
+
}
|
|
1555
|
+
else {
|
|
1556
|
+
// resultVersion 2 or 3: Remove unwanted ruleName
|
|
1557
|
+
for (var _b = 0, results_3 = results; _b < results_3.length; _b++) {
|
|
1558
|
+
var error = results_3[_b];
|
|
1559
|
+
delete error.ruleName;
|
|
1423
1560
|
}
|
|
1424
1561
|
}
|
|
1562
|
+
return results;
|
|
1425
1563
|
}
|
|
1426
1564
|
// Run all rules
|
|
1565
|
+
var ruleListAsync = ruleList.filter(function (rule) { return rule.asynchronous; });
|
|
1566
|
+
var ruleListSync = ruleList.filter(function (rule) { return !rule.asynchronous; });
|
|
1567
|
+
var ruleListAsyncFirst = __spreadArray(__spreadArray([], ruleListAsync, true), ruleListSync, true);
|
|
1568
|
+
var callbackSuccess = function () { return callback(null, formatResults()); };
|
|
1569
|
+
var callbackError = function (error) { return callback(error instanceof Error ? error : new Error(error)); };
|
|
1427
1570
|
try {
|
|
1428
|
-
|
|
1571
|
+
var ruleResults = ruleListAsyncFirst.map(forRule);
|
|
1572
|
+
if (ruleListAsync.length > 0) {
|
|
1573
|
+
Promise.all(ruleResults.slice(0, ruleListAsync.length))
|
|
1574
|
+
.then(callbackSuccess)
|
|
1575
|
+
.catch(callbackError);
|
|
1576
|
+
}
|
|
1577
|
+
else {
|
|
1578
|
+
callbackSuccess();
|
|
1579
|
+
}
|
|
1429
1580
|
}
|
|
1430
1581
|
catch (error) {
|
|
1582
|
+
callbackError(error);
|
|
1583
|
+
}
|
|
1584
|
+
finally {
|
|
1431
1585
|
cache.clear();
|
|
1432
|
-
return callback(error);
|
|
1433
1586
|
}
|
|
1434
|
-
cache.clear();
|
|
1435
|
-
return callback(null, result);
|
|
1436
1587
|
}
|
|
1437
1588
|
/**
|
|
1438
1589
|
* Lints a file containing Markdown content.
|
|
@@ -1480,13 +1631,13 @@ function lintInput(options, synchronous, callback) {
|
|
|
1480
1631
|
callback = callback || function noop() { };
|
|
1481
1632
|
// eslint-disable-next-line unicorn/prefer-spread
|
|
1482
1633
|
var ruleList = rules.concat(options.customRules || []);
|
|
1483
|
-
var ruleErr = validateRuleList(ruleList);
|
|
1634
|
+
var ruleErr = validateRuleList(ruleList, synchronous);
|
|
1484
1635
|
if (ruleErr) {
|
|
1485
1636
|
return callback(ruleErr);
|
|
1486
1637
|
}
|
|
1487
1638
|
var files = [];
|
|
1488
1639
|
if (Array.isArray(options.files)) {
|
|
1489
|
-
files = __spreadArray([], options.files);
|
|
1640
|
+
files = __spreadArray([], options.files, true);
|
|
1490
1641
|
}
|
|
1491
1642
|
else if (options.files) {
|
|
1492
1643
|
files = [String(options.files)];
|
|
@@ -1509,65 +1660,63 @@ function lintInput(options, synchronous, callback) {
|
|
|
1509
1660
|
var fs = options.fs || __webpack_require__(/*! fs */ "?ec0a");
|
|
1510
1661
|
var results = newResults(ruleList);
|
|
1511
1662
|
var done = false;
|
|
1512
|
-
// Linting of strings is always synchronous
|
|
1513
|
-
var syncItem = null;
|
|
1514
|
-
// eslint-disable-next-line jsdoc/require-jsdoc
|
|
1515
|
-
function syncCallback(err, result) {
|
|
1516
|
-
if (err) {
|
|
1517
|
-
done = true;
|
|
1518
|
-
return callback(err);
|
|
1519
|
-
}
|
|
1520
|
-
results[syncItem] = result;
|
|
1521
|
-
return null;
|
|
1522
|
-
}
|
|
1523
|
-
while (!done && (syncItem = stringsKeys.shift())) {
|
|
1524
|
-
lintContent(ruleList, syncItem, strings[syncItem] || "", md, config, frontMatter, handleRuleFailures, noInlineConfig, resultVersion, syncCallback);
|
|
1525
|
-
}
|
|
1526
|
-
if (synchronous) {
|
|
1527
|
-
// Lint files synchronously
|
|
1528
|
-
while (!done && (syncItem = files.shift())) {
|
|
1529
|
-
lintFile(ruleList, syncItem, md, config, frontMatter, handleRuleFailures, noInlineConfig, resultVersion, fs, synchronous, syncCallback);
|
|
1530
|
-
}
|
|
1531
|
-
return done || callback(null, results);
|
|
1532
|
-
}
|
|
1533
|
-
// Lint files asynchronously
|
|
1534
1663
|
var concurrency = 0;
|
|
1535
1664
|
// eslint-disable-next-line jsdoc/require-jsdoc
|
|
1536
|
-
function
|
|
1537
|
-
var
|
|
1665
|
+
function lintWorker() {
|
|
1666
|
+
var currentItem = null;
|
|
1667
|
+
// eslint-disable-next-line jsdoc/require-jsdoc
|
|
1668
|
+
function lintWorkerCallback(err, result) {
|
|
1669
|
+
concurrency--;
|
|
1670
|
+
if (err) {
|
|
1671
|
+
done = true;
|
|
1672
|
+
return callback(err);
|
|
1673
|
+
}
|
|
1674
|
+
results[currentItem] = result;
|
|
1675
|
+
if (!synchronous) {
|
|
1676
|
+
lintWorker();
|
|
1677
|
+
}
|
|
1678
|
+
return null;
|
|
1679
|
+
}
|
|
1538
1680
|
if (done) {
|
|
1539
|
-
//
|
|
1681
|
+
// Abort for error or nothing left to do
|
|
1540
1682
|
}
|
|
1541
|
-
else if (
|
|
1683
|
+
else if (files.length > 0) {
|
|
1684
|
+
// Lint next file
|
|
1542
1685
|
concurrency++;
|
|
1543
|
-
|
|
1544
|
-
|
|
1545
|
-
|
|
1546
|
-
|
|
1547
|
-
|
|
1548
|
-
|
|
1549
|
-
|
|
1550
|
-
|
|
1551
|
-
return null;
|
|
1552
|
-
});
|
|
1686
|
+
currentItem = files.shift();
|
|
1687
|
+
lintFile(ruleList, currentItem, md, config, frontMatter, handleRuleFailures, noInlineConfig, resultVersion, fs, synchronous, lintWorkerCallback);
|
|
1688
|
+
}
|
|
1689
|
+
else if (stringsKeys.length > 0) {
|
|
1690
|
+
// Lint next string
|
|
1691
|
+
concurrency++;
|
|
1692
|
+
currentItem = stringsKeys.shift();
|
|
1693
|
+
lintContent(ruleList, currentItem, strings[currentItem] || "", md, config, frontMatter, handleRuleFailures, noInlineConfig, resultVersion, lintWorkerCallback);
|
|
1553
1694
|
}
|
|
1554
1695
|
else if (concurrency === 0) {
|
|
1696
|
+
// Finish
|
|
1555
1697
|
done = true;
|
|
1556
1698
|
return callback(null, results);
|
|
1557
1699
|
}
|
|
1558
1700
|
return null;
|
|
1559
1701
|
}
|
|
1560
|
-
|
|
1561
|
-
|
|
1562
|
-
|
|
1563
|
-
|
|
1564
|
-
|
|
1565
|
-
|
|
1566
|
-
|
|
1567
|
-
|
|
1568
|
-
|
|
1569
|
-
|
|
1570
|
-
|
|
1702
|
+
if (synchronous) {
|
|
1703
|
+
while (!done) {
|
|
1704
|
+
lintWorker();
|
|
1705
|
+
}
|
|
1706
|
+
}
|
|
1707
|
+
else {
|
|
1708
|
+
// Testing on a Raspberry Pi 4 Model B with an artificial 5ms file access
|
|
1709
|
+
// delay suggests that a concurrency factor of 8 can eliminate the impact
|
|
1710
|
+
// of that delay (i.e., total time is the same as with no delay).
|
|
1711
|
+
lintWorker();
|
|
1712
|
+
lintWorker();
|
|
1713
|
+
lintWorker();
|
|
1714
|
+
lintWorker();
|
|
1715
|
+
lintWorker();
|
|
1716
|
+
lintWorker();
|
|
1717
|
+
lintWorker();
|
|
1718
|
+
lintWorker();
|
|
1719
|
+
}
|
|
1571
1720
|
return null;
|
|
1572
1721
|
}
|
|
1573
1722
|
/**
|
|
@@ -1618,19 +1767,20 @@ function parseConfiguration(name, content, parsers) {
|
|
|
1618
1767
|
var config = null;
|
|
1619
1768
|
var message = "";
|
|
1620
1769
|
var errors = [];
|
|
1770
|
+
var index = 0;
|
|
1621
1771
|
// Try each parser
|
|
1622
1772
|
(parsers || [JSON.parse]).every(function (parser) {
|
|
1623
1773
|
try {
|
|
1624
1774
|
config = parser(content);
|
|
1625
1775
|
}
|
|
1626
1776
|
catch (error) {
|
|
1627
|
-
errors.push(error.message);
|
|
1777
|
+
errors.push("Parser ".concat(index++, ": ").concat(error.message));
|
|
1628
1778
|
}
|
|
1629
1779
|
return !config;
|
|
1630
1780
|
});
|
|
1631
1781
|
// Message if unable to parse
|
|
1632
1782
|
if (!config) {
|
|
1633
|
-
errors.unshift("Unable to parse '"
|
|
1783
|
+
errors.unshift("Unable to parse '".concat(name, "'"));
|
|
1634
1784
|
message = errors.join("; ");
|
|
1635
1785
|
}
|
|
1636
1786
|
return {
|
|
@@ -1729,9 +1879,9 @@ function readConfig(file, parsers, fs, callback) {
|
|
|
1729
1879
|
return callback(new Error(message));
|
|
1730
1880
|
}
|
|
1731
1881
|
// Extend configuration
|
|
1732
|
-
var configExtends = config
|
|
1882
|
+
var configExtends = config.extends;
|
|
1733
1883
|
if (configExtends) {
|
|
1734
|
-
delete config
|
|
1884
|
+
delete config.extends;
|
|
1735
1885
|
return resolveConfigExtends(file, configExtends, fs, function (_, resolvedExtends) { return readConfig(resolvedExtends, parsers, fs, function (errr, extendsConfig) {
|
|
1736
1886
|
if (errr) {
|
|
1737
1887
|
return callback(errr);
|
|
@@ -1776,9 +1926,9 @@ function readConfigSync(file, parsers, fs) {
|
|
|
1776
1926
|
throw new Error(message);
|
|
1777
1927
|
}
|
|
1778
1928
|
// Extend configuration
|
|
1779
|
-
var configExtends = config
|
|
1929
|
+
var configExtends = config.extends;
|
|
1780
1930
|
if (configExtends) {
|
|
1781
|
-
delete config
|
|
1931
|
+
delete config.extends;
|
|
1782
1932
|
var resolvedExtends = resolveConfigExtendsSync(file, configExtends, fs);
|
|
1783
1933
|
return __assign(__assign({}, readConfigSync(resolvedExtends, parsers, fs)), config);
|
|
1784
1934
|
}
|
|
@@ -1790,7 +1940,7 @@ function readConfigSync(file, parsers, fs) {
|
|
|
1790
1940
|
* @returns {string} SemVer string.
|
|
1791
1941
|
*/
|
|
1792
1942
|
function getVersion() {
|
|
1793
|
-
return __webpack_require__(/*!
|
|
1943
|
+
return (__webpack_require__(/*! ./constants */ "../lib/constants.js").version);
|
|
1794
1944
|
}
|
|
1795
1945
|
// Export a/synchronous/Promise APIs
|
|
1796
1946
|
markdownlint.sync = markdownlintSync;
|
|
@@ -1844,7 +1994,7 @@ module.exports = {
|
|
|
1844
1994
|
"use strict";
|
|
1845
1995
|
// @ts-check
|
|
1846
1996
|
|
|
1847
|
-
var addErrorDetailIf = __webpack_require__(/*! ../helpers */ "../helpers/helpers.js").addErrorDetailIf;
|
|
1997
|
+
var addErrorDetailIf = (__webpack_require__(/*! ../helpers */ "../helpers/helpers.js").addErrorDetailIf);
|
|
1848
1998
|
module.exports = {
|
|
1849
1999
|
"names": ["MD002", "first-heading-h1", "first-header-h1"],
|
|
1850
2000
|
"description": "First heading should be a top-level heading",
|
|
@@ -1922,7 +2072,7 @@ module.exports = {
|
|
|
1922
2072
|
// @ts-check
|
|
1923
2073
|
|
|
1924
2074
|
var _a = __webpack_require__(/*! ../helpers */ "../helpers/helpers.js"), addErrorDetailIf = _a.addErrorDetailIf, listItemMarkerRe = _a.listItemMarkerRe, unorderedListStyleFor = _a.unorderedListStyleFor;
|
|
1925
|
-
var flattenedLists = __webpack_require__(/*! ./cache */ "../lib/cache.js").flattenedLists;
|
|
2075
|
+
var flattenedLists = (__webpack_require__(/*! ./cache */ "../lib/cache.js").flattenedLists);
|
|
1926
2076
|
var expectedStyleToMarker = {
|
|
1927
2077
|
"dash": "-",
|
|
1928
2078
|
"plus": "+",
|
|
@@ -1967,8 +2117,8 @@ module.exports = {
|
|
|
1967
2117
|
var match = item.line.match(listItemMarkerRe);
|
|
1968
2118
|
if (match) {
|
|
1969
2119
|
var column = match.index + 1;
|
|
1970
|
-
var
|
|
1971
|
-
range = [column,
|
|
2120
|
+
var length = match[0].length;
|
|
2121
|
+
range = [column, length];
|
|
1972
2122
|
fixInfo = {
|
|
1973
2123
|
"editColumn": match[1].length + 1,
|
|
1974
2124
|
"deleteCount": 1,
|
|
@@ -1995,7 +2145,7 @@ module.exports = {
|
|
|
1995
2145
|
// @ts-check
|
|
1996
2146
|
|
|
1997
2147
|
var _a = __webpack_require__(/*! ../helpers */ "../helpers/helpers.js"), addError = _a.addError, addErrorDetailIf = _a.addErrorDetailIf, indentFor = _a.indentFor, listItemMarkerRe = _a.listItemMarkerRe, orderedListItemMarkerRe = _a.orderedListItemMarkerRe, rangeFromRegExp = _a.rangeFromRegExp;
|
|
1998
|
-
var flattenedLists = __webpack_require__(/*! ./cache */ "../lib/cache.js").flattenedLists;
|
|
2148
|
+
var flattenedLists = (__webpack_require__(/*! ./cache */ "../lib/cache.js").flattenedLists);
|
|
1999
2149
|
module.exports = {
|
|
2000
2150
|
"names": ["MD005", "list-indent"],
|
|
2001
2151
|
"description": "Inconsistent indentation for list items at the same level",
|
|
@@ -2025,8 +2175,8 @@ module.exports = {
|
|
|
2025
2175
|
}
|
|
2026
2176
|
else {
|
|
2027
2177
|
var detail = endMatching ?
|
|
2028
|
-
"Expected: ("
|
|
2029
|
-
"Expected: "
|
|
2178
|
+
"Expected: (".concat(expectedEnd, "); Actual: (").concat(actualEnd, ")") :
|
|
2179
|
+
"Expected: ".concat(expectedIndent, "; Actual: ").concat(actualIndent);
|
|
2030
2180
|
var expected = endMatching ?
|
|
2031
2181
|
expectedEnd - markerLength :
|
|
2032
2182
|
expectedIndent;
|
|
@@ -2059,7 +2209,7 @@ module.exports = {
|
|
|
2059
2209
|
// @ts-check
|
|
2060
2210
|
|
|
2061
2211
|
var _a = __webpack_require__(/*! ../helpers */ "../helpers/helpers.js"), addErrorDetailIf = _a.addErrorDetailIf, listItemMarkerRe = _a.listItemMarkerRe, rangeFromRegExp = _a.rangeFromRegExp;
|
|
2062
|
-
var flattenedLists = __webpack_require__(/*! ./cache */ "../lib/cache.js").flattenedLists;
|
|
2212
|
+
var flattenedLists = (__webpack_require__(/*! ./cache */ "../lib/cache.js").flattenedLists);
|
|
2063
2213
|
module.exports = {
|
|
2064
2214
|
"names": ["MD006", "ul-start-left"],
|
|
2065
2215
|
"description": "Consider starting bulleted lists at the beginning of the line",
|
|
@@ -2091,7 +2241,7 @@ module.exports = {
|
|
|
2091
2241
|
// @ts-check
|
|
2092
2242
|
|
|
2093
2243
|
var _a = __webpack_require__(/*! ../helpers */ "../helpers/helpers.js"), addErrorDetailIf = _a.addErrorDetailIf, indentFor = _a.indentFor, listItemMarkerRe = _a.listItemMarkerRe;
|
|
2094
|
-
var flattenedLists = __webpack_require__(/*! ./cache */ "../lib/cache.js").flattenedLists;
|
|
2244
|
+
var flattenedLists = (__webpack_require__(/*! ./cache */ "../lib/cache.js").flattenedLists);
|
|
2095
2245
|
module.exports = {
|
|
2096
2246
|
"names": ["MD007", "ul-indent"],
|
|
2097
2247
|
"description": "Unordered list indentation",
|
|
@@ -2099,12 +2249,13 @@ module.exports = {
|
|
|
2099
2249
|
"function": function MD007(params, onError) {
|
|
2100
2250
|
var indent = Number(params.config.indent || 2);
|
|
2101
2251
|
var startIndented = !!params.config.start_indented;
|
|
2252
|
+
var startIndent = Number(params.config.start_indent || indent);
|
|
2102
2253
|
flattenedLists().forEach(function (list) {
|
|
2103
2254
|
if (list.unordered && list.parentsUnordered) {
|
|
2104
2255
|
list.items.forEach(function (item) {
|
|
2105
2256
|
var lineNumber = item.lineNumber, line = item.line;
|
|
2106
|
-
var
|
|
2107
|
-
|
|
2257
|
+
var expectedIndent = (startIndented ? startIndent : 0) +
|
|
2258
|
+
(list.nesting * indent);
|
|
2108
2259
|
var actualIndent = indentFor(item);
|
|
2109
2260
|
var range = null;
|
|
2110
2261
|
var editColumn = 1;
|
|
@@ -2137,7 +2288,7 @@ module.exports = {
|
|
|
2137
2288
|
// @ts-check
|
|
2138
2289
|
|
|
2139
2290
|
var _a = __webpack_require__(/*! ../helpers */ "../helpers/helpers.js"), addError = _a.addError, filterTokens = _a.filterTokens, forEachInlineCodeSpan = _a.forEachInlineCodeSpan, forEachLine = _a.forEachLine, includesSorted = _a.includesSorted, newLineRe = _a.newLineRe, numericSortAscending = _a.numericSortAscending;
|
|
2140
|
-
var lineMetadata = __webpack_require__(/*! ./cache */ "../lib/cache.js").lineMetadata;
|
|
2291
|
+
var lineMetadata = (__webpack_require__(/*! ./cache */ "../lib/cache.js").lineMetadata);
|
|
2141
2292
|
module.exports = {
|
|
2142
2293
|
"names": ["MD009", "no-trailing-spaces"],
|
|
2143
2294
|
"description": "Trailing spaces",
|
|
@@ -2212,8 +2363,8 @@ module.exports = {
|
|
|
2212
2363
|
"use strict";
|
|
2213
2364
|
// @ts-check
|
|
2214
2365
|
|
|
2215
|
-
var _a = __webpack_require__(/*! ../helpers */ "../helpers/helpers.js"), addError = _a.addError, forEachLine = _a.forEachLine;
|
|
2216
|
-
var
|
|
2366
|
+
var _a = __webpack_require__(/*! ../helpers */ "../helpers/helpers.js"), addError = _a.addError, forEachLine = _a.forEachLine, overlapsAnyRange = _a.overlapsAnyRange;
|
|
2367
|
+
var _b = __webpack_require__(/*! ./cache */ "../lib/cache.js"), codeBlockAndSpanRanges = _b.codeBlockAndSpanRanges, lineMetadata = _b.lineMetadata;
|
|
2217
2368
|
var tabRe = /\t+/g;
|
|
2218
2369
|
module.exports = {
|
|
2219
2370
|
"names": ["MD010", "no-hard-tabs"],
|
|
@@ -2221,22 +2372,26 @@ module.exports = {
|
|
|
2221
2372
|
"tags": ["whitespace", "hard_tab"],
|
|
2222
2373
|
"function": function MD010(params, onError) {
|
|
2223
2374
|
var codeBlocks = params.config.code_blocks;
|
|
2224
|
-
var
|
|
2375
|
+
var includeCode = (codeBlocks === undefined) ? true : !!codeBlocks;
|
|
2225
2376
|
var spacesPerTab = params.config.spaces_per_tab;
|
|
2226
2377
|
var spaceMultiplier = (spacesPerTab === undefined) ?
|
|
2227
2378
|
1 :
|
|
2228
2379
|
Math.max(0, Number(spacesPerTab));
|
|
2380
|
+
var exclusions = includeCode ? [] : codeBlockAndSpanRanges();
|
|
2229
2381
|
forEachLine(lineMetadata(), function (line, lineIndex, inCode) {
|
|
2230
|
-
if (
|
|
2382
|
+
if (includeCode || !inCode) {
|
|
2231
2383
|
var match = null;
|
|
2232
2384
|
while ((match = tabRe.exec(line)) !== null) {
|
|
2233
|
-
var
|
|
2234
|
-
var
|
|
2235
|
-
|
|
2236
|
-
|
|
2237
|
-
"
|
|
2238
|
-
|
|
2239
|
-
|
|
2385
|
+
var index = match.index;
|
|
2386
|
+
var column = index + 1;
|
|
2387
|
+
var length = match[0].length;
|
|
2388
|
+
if (!overlapsAnyRange(exclusions, lineIndex, index, length)) {
|
|
2389
|
+
addError(onError, lineIndex + 1, "Column: " + column, null, [column, length], {
|
|
2390
|
+
"editColumn": column,
|
|
2391
|
+
"deleteCount": length,
|
|
2392
|
+
"insertText": "".padEnd(length * spaceMultiplier)
|
|
2393
|
+
});
|
|
2394
|
+
}
|
|
2240
2395
|
}
|
|
2241
2396
|
}
|
|
2242
2397
|
});
|
|
@@ -2256,28 +2411,28 @@ module.exports = {
|
|
|
2256
2411
|
// @ts-check
|
|
2257
2412
|
|
|
2258
2413
|
var _a = __webpack_require__(/*! ../helpers */ "../helpers/helpers.js"), addError = _a.addError, forEachLine = _a.forEachLine, overlapsAnyRange = _a.overlapsAnyRange;
|
|
2259
|
-
var _b = __webpack_require__(/*! ./cache */ "../lib/cache.js"),
|
|
2414
|
+
var _b = __webpack_require__(/*! ./cache */ "../lib/cache.js"), codeBlockAndSpanRanges = _b.codeBlockAndSpanRanges, lineMetadata = _b.lineMetadata;
|
|
2260
2415
|
var reversedLinkRe = /(^|[^\\])\(([^)]+)\)\[([^\]^][^\]]*)](?!\()/g;
|
|
2261
2416
|
module.exports = {
|
|
2262
2417
|
"names": ["MD011", "no-reversed-links"],
|
|
2263
2418
|
"description": "Reversed link syntax",
|
|
2264
2419
|
"tags": ["links"],
|
|
2265
2420
|
"function": function MD011(params, onError) {
|
|
2266
|
-
var exclusions =
|
|
2421
|
+
var exclusions = codeBlockAndSpanRanges();
|
|
2267
2422
|
forEachLine(lineMetadata(), function (line, lineIndex, inCode, onFence) {
|
|
2268
2423
|
if (!inCode && !onFence) {
|
|
2269
2424
|
var match = null;
|
|
2270
2425
|
while ((match = reversedLinkRe.exec(line)) !== null) {
|
|
2271
2426
|
var reversedLink = match[0], preChar = match[1], linkText = match[2], linkDestination = match[3];
|
|
2272
2427
|
var index = match.index + preChar.length;
|
|
2273
|
-
var
|
|
2428
|
+
var length = match[0].length - preChar.length;
|
|
2274
2429
|
if (!linkText.endsWith("\\") &&
|
|
2275
2430
|
!linkDestination.endsWith("\\") &&
|
|
2276
|
-
!overlapsAnyRange(exclusions, lineIndex, index,
|
|
2277
|
-
addError(onError, lineIndex + 1, reversedLink.slice(preChar.length), null, [index + 1,
|
|
2431
|
+
!overlapsAnyRange(exclusions, lineIndex, index, length)) {
|
|
2432
|
+
addError(onError, lineIndex + 1, reversedLink.slice(preChar.length), null, [index + 1, length], {
|
|
2278
2433
|
"editColumn": index + 1,
|
|
2279
|
-
"deleteCount":
|
|
2280
|
-
"insertText": "["
|
|
2434
|
+
"deleteCount": length,
|
|
2435
|
+
"insertText": "[".concat(linkText, "](").concat(linkDestination, ")")
|
|
2281
2436
|
});
|
|
2282
2437
|
}
|
|
2283
2438
|
}
|
|
@@ -2299,7 +2454,7 @@ module.exports = {
|
|
|
2299
2454
|
// @ts-check
|
|
2300
2455
|
|
|
2301
2456
|
var _a = __webpack_require__(/*! ../helpers */ "../helpers/helpers.js"), addErrorDetailIf = _a.addErrorDetailIf, forEachLine = _a.forEachLine;
|
|
2302
|
-
var lineMetadata = __webpack_require__(/*! ./cache */ "../lib/cache.js").lineMetadata;
|
|
2457
|
+
var lineMetadata = (__webpack_require__(/*! ./cache */ "../lib/cache.js").lineMetadata);
|
|
2303
2458
|
module.exports = {
|
|
2304
2459
|
"names": ["MD012", "no-multiple-blanks"],
|
|
2305
2460
|
"description": "Multiple consecutive blank lines",
|
|
@@ -2331,7 +2486,7 @@ module.exports = {
|
|
|
2331
2486
|
// @ts-check
|
|
2332
2487
|
|
|
2333
2488
|
var _a = __webpack_require__(/*! ../helpers */ "../helpers/helpers.js"), addErrorDetailIf = _a.addErrorDetailIf, filterTokens = _a.filterTokens, forEachHeading = _a.forEachHeading, forEachLine = _a.forEachLine, includesSorted = _a.includesSorted;
|
|
2334
|
-
var lineMetadata = __webpack_require__(/*! ./cache */ "../lib/cache.js").lineMetadata;
|
|
2489
|
+
var lineMetadata = (__webpack_require__(/*! ./cache */ "../lib/cache.js").lineMetadata);
|
|
2335
2490
|
var longLineRePrefix = "^.{";
|
|
2336
2491
|
var longLineRePostfixRelaxed = "}.*\\s.*$";
|
|
2337
2492
|
var longLineRePostfixStrict = "}.+$";
|
|
@@ -2441,8 +2596,8 @@ module.exports = {
|
|
|
2441
2596
|
var match = dollarCommandRe.exec(line);
|
|
2442
2597
|
if (match) {
|
|
2443
2598
|
var column = match[1].length + 1;
|
|
2444
|
-
var
|
|
2445
|
-
dollarInstances.push([i, lineTrim, column,
|
|
2599
|
+
var length = match[2].length;
|
|
2600
|
+
dollarInstances.push([i, lineTrim, column, length]);
|
|
2446
2601
|
}
|
|
2447
2602
|
else {
|
|
2448
2603
|
allDollars = false;
|
|
@@ -2476,7 +2631,7 @@ module.exports = {
|
|
|
2476
2631
|
// @ts-check
|
|
2477
2632
|
|
|
2478
2633
|
var _a = __webpack_require__(/*! ../helpers */ "../helpers/helpers.js"), addErrorContext = _a.addErrorContext, forEachLine = _a.forEachLine;
|
|
2479
|
-
var lineMetadata = __webpack_require__(/*! ./cache */ "../lib/cache.js").lineMetadata;
|
|
2634
|
+
var lineMetadata = (__webpack_require__(/*! ./cache */ "../lib/cache.js").lineMetadata);
|
|
2480
2635
|
module.exports = {
|
|
2481
2636
|
"names": ["MD018", "no-missing-space-atx"],
|
|
2482
2637
|
"description": "No space after hash on atx style heading",
|
|
@@ -2544,7 +2699,7 @@ module.exports = {
|
|
|
2544
2699
|
// @ts-check
|
|
2545
2700
|
|
|
2546
2701
|
var _a = __webpack_require__(/*! ../helpers */ "../helpers/helpers.js"), addErrorContext = _a.addErrorContext, forEachLine = _a.forEachLine;
|
|
2547
|
-
var lineMetadata = __webpack_require__(/*! ./cache */ "../lib/cache.js").lineMetadata;
|
|
2702
|
+
var lineMetadata = (__webpack_require__(/*! ./cache */ "../lib/cache.js").lineMetadata);
|
|
2548
2703
|
module.exports = {
|
|
2549
2704
|
"names": ["MD020", "no-missing-space-closed-atx"],
|
|
2550
2705
|
"description": "No space inside hashes on closed atx style heading",
|
|
@@ -2559,7 +2714,7 @@ module.exports = {
|
|
|
2559
2714
|
var rightHashLength = rightHash.length;
|
|
2560
2715
|
var left = !leftSpaceLength;
|
|
2561
2716
|
var right = !rightSpaceLength || rightEscape;
|
|
2562
|
-
var rightEscapeReplacement = rightEscape ? rightEscape
|
|
2717
|
+
var rightEscapeReplacement = rightEscape ? "".concat(rightEscape, " ") : "";
|
|
2563
2718
|
if (left || right) {
|
|
2564
2719
|
var range = left ?
|
|
2565
2720
|
[
|
|
@@ -2573,7 +2728,7 @@ module.exports = {
|
|
|
2573
2728
|
addErrorContext(onError, lineIndex + 1, line.trim(), left, right, range, {
|
|
2574
2729
|
"editColumn": 1,
|
|
2575
2730
|
"deleteCount": line.length,
|
|
2576
|
-
"insertText": leftHash
|
|
2731
|
+
"insertText": "".concat(leftHash, " ").concat(content, " ").concat(rightEscapeReplacement).concat(rightHash)
|
|
2577
2732
|
});
|
|
2578
2733
|
}
|
|
2579
2734
|
}
|
|
@@ -2609,7 +2764,7 @@ module.exports = {
|
|
|
2609
2764
|
var left = leftSpaceLength > 1;
|
|
2610
2765
|
var right = rightSpaceLength > 1;
|
|
2611
2766
|
if (left || right) {
|
|
2612
|
-
var
|
|
2767
|
+
var length = line.length;
|
|
2613
2768
|
var leftHashLength = leftHash.length;
|
|
2614
2769
|
var rightHashLength = rightHash.length;
|
|
2615
2770
|
var range = left ?
|
|
@@ -2618,13 +2773,13 @@ module.exports = {
|
|
|
2618
2773
|
leftHashLength + leftSpaceLength + 1
|
|
2619
2774
|
] :
|
|
2620
2775
|
[
|
|
2621
|
-
|
|
2776
|
+
length - trailSpaceLength - rightHashLength - rightSpaceLength,
|
|
2622
2777
|
rightSpaceLength + rightHashLength + 1
|
|
2623
2778
|
];
|
|
2624
2779
|
addErrorContext(onError, lineNumber, line.trim(), left, right, range, {
|
|
2625
2780
|
"editColumn": 1,
|
|
2626
|
-
"deleteCount":
|
|
2627
|
-
"insertText": leftHash
|
|
2781
|
+
"deleteCount": length,
|
|
2782
|
+
"insertText": "".concat(leftHash, " ").concat(content, " ").concat(rightHash)
|
|
2628
2783
|
});
|
|
2629
2784
|
}
|
|
2630
2785
|
}
|
|
@@ -2829,10 +2984,10 @@ module.exports = {
|
|
|
2829
2984
|
if (match && !endOfLineHtmlEntityRe.test(trimmedLine)) {
|
|
2830
2985
|
var fullMatch = match[0];
|
|
2831
2986
|
var column = match.index + 1;
|
|
2832
|
-
var
|
|
2833
|
-
addError(onError, lineNumber, "Punctuation: '"
|
|
2987
|
+
var length = fullMatch.length;
|
|
2988
|
+
addError(onError, lineNumber, "Punctuation: '".concat(fullMatch, "'"), null, [column, length], {
|
|
2834
2989
|
"editColumn": column,
|
|
2835
|
-
"deleteCount":
|
|
2990
|
+
"deleteCount": length
|
|
2836
2991
|
});
|
|
2837
2992
|
}
|
|
2838
2993
|
});
|
|
@@ -2906,7 +3061,7 @@ module.exports = {
|
|
|
2906
3061
|
"use strict";
|
|
2907
3062
|
// @ts-check
|
|
2908
3063
|
|
|
2909
|
-
var addError = __webpack_require__(/*! ../helpers */ "../helpers/helpers.js").addError;
|
|
3064
|
+
var addError = (__webpack_require__(/*! ../helpers */ "../helpers/helpers.js").addError);
|
|
2910
3065
|
module.exports = {
|
|
2911
3066
|
"names": ["MD028", "no-blanks-blockquote"],
|
|
2912
3067
|
"description": "Blank line inside blockquote",
|
|
@@ -2942,7 +3097,7 @@ module.exports = {
|
|
|
2942
3097
|
// @ts-check
|
|
2943
3098
|
|
|
2944
3099
|
var _a = __webpack_require__(/*! ../helpers */ "../helpers/helpers.js"), addErrorDetailIf = _a.addErrorDetailIf, listItemMarkerRe = _a.listItemMarkerRe, orderedListItemMarkerRe = _a.orderedListItemMarkerRe, rangeFromRegExp = _a.rangeFromRegExp;
|
|
2945
|
-
var flattenedLists = __webpack_require__(/*! ./cache */ "../lib/cache.js").flattenedLists;
|
|
3100
|
+
var flattenedLists = (__webpack_require__(/*! ./cache */ "../lib/cache.js").flattenedLists);
|
|
2946
3101
|
var listStyleExamples = {
|
|
2947
3102
|
"one": "1/1/1",
|
|
2948
3103
|
"ordered": "1/2/3",
|
|
@@ -3011,8 +3166,8 @@ module.exports = {
|
|
|
3011
3166
|
"use strict";
|
|
3012
3167
|
// @ts-check
|
|
3013
3168
|
|
|
3014
|
-
var addErrorDetailIf = __webpack_require__(/*! ../helpers */ "../helpers/helpers.js").addErrorDetailIf;
|
|
3015
|
-
var flattenedLists = __webpack_require__(/*! ./cache */ "../lib/cache.js").flattenedLists;
|
|
3169
|
+
var addErrorDetailIf = (__webpack_require__(/*! ../helpers */ "../helpers/helpers.js").addErrorDetailIf);
|
|
3170
|
+
var flattenedLists = (__webpack_require__(/*! ./cache */ "../lib/cache.js").flattenedLists);
|
|
3016
3171
|
module.exports = {
|
|
3017
3172
|
"names": ["MD030", "list-marker-space"],
|
|
3018
3173
|
"description": "Spaces after list markers",
|
|
@@ -3061,7 +3216,7 @@ module.exports = {
|
|
|
3061
3216
|
// @ts-check
|
|
3062
3217
|
|
|
3063
3218
|
var _a = __webpack_require__(/*! ../helpers */ "../helpers/helpers.js"), addErrorContext = _a.addErrorContext, forEachLine = _a.forEachLine, isBlankLine = _a.isBlankLine;
|
|
3064
|
-
var lineMetadata = __webpack_require__(/*! ./cache */ "../lib/cache.js").lineMetadata;
|
|
3219
|
+
var lineMetadata = (__webpack_require__(/*! ./cache */ "../lib/cache.js").lineMetadata);
|
|
3065
3220
|
var codeFencePrefixRe = /^(.*?)\s*[`~]/;
|
|
3066
3221
|
module.exports = {
|
|
3067
3222
|
"names": ["MD031", "blanks-around-fences"],
|
|
@@ -3080,7 +3235,7 @@ module.exports = {
|
|
|
3080
3235
|
var _a = line.match(codeFencePrefixRe) || [], prefix = _a[1];
|
|
3081
3236
|
var fixInfo = (prefix === undefined) ? null : {
|
|
3082
3237
|
"lineNumber": i + (onTopFence ? 1 : 2),
|
|
3083
|
-
"insertText": prefix
|
|
3238
|
+
"insertText": "".concat(prefix, "\n")
|
|
3084
3239
|
};
|
|
3085
3240
|
addErrorContext(onError, i + 1, lines[i].trim(), null, null, null, fixInfo);
|
|
3086
3241
|
}
|
|
@@ -3101,7 +3256,7 @@ module.exports = {
|
|
|
3101
3256
|
// @ts-check
|
|
3102
3257
|
|
|
3103
3258
|
var _a = __webpack_require__(/*! ../helpers */ "../helpers/helpers.js"), addErrorContext = _a.addErrorContext, isBlankLine = _a.isBlankLine;
|
|
3104
|
-
var flattenedLists = __webpack_require__(/*! ./cache */ "../lib/cache.js").flattenedLists;
|
|
3259
|
+
var flattenedLists = (__webpack_require__(/*! ./cache */ "../lib/cache.js").flattenedLists);
|
|
3105
3260
|
var quotePrefixRe = /^[>\s]*/;
|
|
3106
3261
|
module.exports = {
|
|
3107
3262
|
"names": ["MD032", "blanks-around-lists"],
|
|
@@ -3115,7 +3270,7 @@ module.exports = {
|
|
|
3115
3270
|
var line = lines[firstIndex];
|
|
3116
3271
|
var quotePrefix = line.match(quotePrefixRe)[0].trimEnd();
|
|
3117
3272
|
addErrorContext(onError, firstIndex + 1, line.trim(), null, null, null, {
|
|
3118
|
-
"insertText": quotePrefix
|
|
3273
|
+
"insertText": "".concat(quotePrefix, "\n")
|
|
3119
3274
|
});
|
|
3120
3275
|
}
|
|
3121
3276
|
var lastIndex = list.lastLineIndex - 1;
|
|
@@ -3124,7 +3279,7 @@ module.exports = {
|
|
|
3124
3279
|
var quotePrefix = line.match(quotePrefixRe)[0].trimEnd();
|
|
3125
3280
|
addErrorContext(onError, lastIndex + 1, line.trim(), null, null, null, {
|
|
3126
3281
|
"lineNumber": lastIndex + 2,
|
|
3127
|
-
"insertText": quotePrefix
|
|
3282
|
+
"insertText": "".concat(quotePrefix, "\n")
|
|
3128
3283
|
});
|
|
3129
3284
|
}
|
|
3130
3285
|
});
|
|
@@ -3143,11 +3298,10 @@ module.exports = {
|
|
|
3143
3298
|
"use strict";
|
|
3144
3299
|
// @ts-check
|
|
3145
3300
|
|
|
3146
|
-
var _a = __webpack_require__(/*! ../helpers */ "../helpers/helpers.js"), addError = _a.addError, forEachLine = _a.forEachLine, unescapeMarkdown = _a.unescapeMarkdown;
|
|
3147
|
-
var
|
|
3301
|
+
var _a = __webpack_require__(/*! ../helpers */ "../helpers/helpers.js"), addError = _a.addError, forEachLine = _a.forEachLine, overlapsAnyRange = _a.overlapsAnyRange, unescapeMarkdown = _a.unescapeMarkdown;
|
|
3302
|
+
var _b = __webpack_require__(/*! ./cache */ "../lib/cache.js"), codeBlockAndSpanRanges = _b.codeBlockAndSpanRanges, lineMetadata = _b.lineMetadata;
|
|
3148
3303
|
var htmlElementRe = /<(([A-Za-z][A-Za-z0-9-]*)(?:\s[^>]*)?)\/?>/g;
|
|
3149
3304
|
var linkDestinationRe = /]\(\s*$/;
|
|
3150
|
-
var inlineCodeRe = /^[^`]*(`+[^`]+`+[^`]+)*`+[^`]*$/;
|
|
3151
3305
|
// See https://spec.commonmark.org/0.29/#autolinks
|
|
3152
3306
|
var emailAddressRe =
|
|
3153
3307
|
// eslint-disable-next-line max-len
|
|
@@ -3160,6 +3314,7 @@ module.exports = {
|
|
|
3160
3314
|
var allowedElements = params.config.allowed_elements;
|
|
3161
3315
|
allowedElements = Array.isArray(allowedElements) ? allowedElements : [];
|
|
3162
3316
|
allowedElements = allowedElements.map(function (element) { return element.toLowerCase(); });
|
|
3317
|
+
var exclusions = codeBlockAndSpanRanges();
|
|
3163
3318
|
forEachLine(lineMetadata(), function (line, lineIndex, inCode) {
|
|
3164
3319
|
var match = null;
|
|
3165
3320
|
// eslint-disable-next-line no-unmodified-loop-condition
|
|
@@ -3167,12 +3322,12 @@ module.exports = {
|
|
|
3167
3322
|
var tag = match[0], content = match[1], element = match[2];
|
|
3168
3323
|
if (!allowedElements.includes(element.toLowerCase()) &&
|
|
3169
3324
|
!tag.endsWith("\\>") &&
|
|
3170
|
-
!emailAddressRe.test(content)
|
|
3325
|
+
!emailAddressRe.test(content) &&
|
|
3326
|
+
!overlapsAnyRange(exclusions, lineIndex, match.index, match[0].length)) {
|
|
3171
3327
|
var prefix = line.substring(0, match.index);
|
|
3172
|
-
if (!linkDestinationRe.test(prefix)
|
|
3328
|
+
if (!linkDestinationRe.test(prefix)) {
|
|
3173
3329
|
var unescaped = unescapeMarkdown(prefix + "<", "_");
|
|
3174
|
-
if (!unescaped.endsWith("_")
|
|
3175
|
-
((unescaped + "`").match(/`/g).length % 2)) {
|
|
3330
|
+
if (!unescaped.endsWith("_")) {
|
|
3176
3331
|
addError(onError, lineIndex + 1, "Element: " + element, null, [match.index + 1, tag.length]);
|
|
3177
3332
|
}
|
|
3178
3333
|
}
|
|
@@ -3232,7 +3387,7 @@ module.exports = {
|
|
|
3232
3387
|
var fixInfo = range ? {
|
|
3233
3388
|
"editColumn": range[0],
|
|
3234
3389
|
"deleteCount": range[1],
|
|
3235
|
-
"insertText": "<"
|
|
3390
|
+
"insertText": "<".concat(bareUrl, ">")
|
|
3236
3391
|
} : null;
|
|
3237
3392
|
addErrorContext(onError, lineNumber, bareUrl, null, null, range, fixInfo);
|
|
3238
3393
|
}
|
|
@@ -3262,12 +3417,12 @@ module.exports = {
|
|
|
3262
3417
|
"tags": ["hr"],
|
|
3263
3418
|
"function": function MD035(params, onError) {
|
|
3264
3419
|
var style = String(params.config.style || "consistent");
|
|
3265
|
-
filterTokens(params, "hr", function
|
|
3266
|
-
var
|
|
3420
|
+
filterTokens(params, "hr", function (token) {
|
|
3421
|
+
var lineNumber = token.lineNumber, markup = token.markup;
|
|
3267
3422
|
if (style === "consistent") {
|
|
3268
|
-
style =
|
|
3423
|
+
style = markup;
|
|
3269
3424
|
}
|
|
3270
|
-
addErrorDetailIf(onError,
|
|
3425
|
+
addErrorDetailIf(onError, lineNumber, style, markup);
|
|
3271
3426
|
});
|
|
3272
3427
|
}
|
|
3273
3428
|
};
|
|
@@ -3350,8 +3505,9 @@ module.exports = {
|
|
|
3350
3505
|
// @ts-check
|
|
3351
3506
|
|
|
3352
3507
|
var _a = __webpack_require__(/*! ../helpers */ "../helpers/helpers.js"), addErrorContext = _a.addErrorContext, emphasisMarkersInContent = _a.emphasisMarkersInContent, forEachLine = _a.forEachLine, isBlankLine = _a.isBlankLine;
|
|
3353
|
-
var lineMetadata = __webpack_require__(/*! ./cache */ "../lib/cache.js").lineMetadata;
|
|
3508
|
+
var lineMetadata = (__webpack_require__(/*! ./cache */ "../lib/cache.js").lineMetadata);
|
|
3354
3509
|
var emphasisRe = /(^|[^\\]|\\\\)(?:(\*\*?\*?)|(__?_?))/g;
|
|
3510
|
+
var embeddedUnderscoreRe = /([A-Za-z0-9])_([A-Za-z0-9])/g;
|
|
3355
3511
|
var asteriskListItemMarkerRe = /^([\s>]*)\*(\s+)/;
|
|
3356
3512
|
var leftSpaceRe = /^\s+/;
|
|
3357
3513
|
var rightSpaceRe = /\s+$/;
|
|
@@ -3390,20 +3546,20 @@ module.exports = {
|
|
|
3390
3546
|
var contextEnd = matchIndex + contextLength;
|
|
3391
3547
|
var context = line.substring(contextStart, contextEnd);
|
|
3392
3548
|
var column = contextStart + 1;
|
|
3393
|
-
var
|
|
3549
|
+
var length = contextEnd - contextStart;
|
|
3394
3550
|
var leftMarker = line.substring(contextStart, emphasisIndex);
|
|
3395
3551
|
var rightMarker = match ? (match[2] || match[3]) : "";
|
|
3396
|
-
var fixedText = ""
|
|
3552
|
+
var fixedText = "".concat(leftMarker).concat(content.trim()).concat(rightMarker);
|
|
3397
3553
|
return [
|
|
3398
3554
|
onError,
|
|
3399
3555
|
lineIndex + 1,
|
|
3400
3556
|
context,
|
|
3401
3557
|
leftSpace,
|
|
3402
3558
|
rightSpace,
|
|
3403
|
-
[column,
|
|
3559
|
+
[column, length],
|
|
3404
3560
|
{
|
|
3405
3561
|
"editColumn": column,
|
|
3406
|
-
"deleteCount":
|
|
3562
|
+
"deleteCount": length,
|
|
3407
3563
|
"insertText": fixedText
|
|
3408
3564
|
}
|
|
3409
3565
|
];
|
|
@@ -3431,14 +3587,15 @@ module.exports = {
|
|
|
3431
3587
|
// Emphasis has no meaning here
|
|
3432
3588
|
return;
|
|
3433
3589
|
}
|
|
3590
|
+
var patchedLine = line.replace(embeddedUnderscoreRe, "$1 $2");
|
|
3434
3591
|
if (onItemStart) {
|
|
3435
3592
|
// Trim overlapping '*' list item marker
|
|
3436
|
-
|
|
3593
|
+
patchedLine = patchedLine.replace(asteriskListItemMarkerRe, "$1 $2");
|
|
3437
3594
|
}
|
|
3438
3595
|
var match = null;
|
|
3439
3596
|
// Match all emphasis-looking runs in the line...
|
|
3440
|
-
while ((match = emphasisRe.exec(
|
|
3441
|
-
var ignoreMarkersForLine = ignoreMarkersByLine[lineIndex]
|
|
3597
|
+
while ((match = emphasisRe.exec(patchedLine))) {
|
|
3598
|
+
var ignoreMarkersForLine = ignoreMarkersByLine[lineIndex];
|
|
3442
3599
|
var matchIndex = match.index + match[1].length;
|
|
3443
3600
|
if (ignoreMarkersForLine.includes(matchIndex)) {
|
|
3444
3601
|
// Ignore emphasis markers inside code spans and links
|
|
@@ -3581,7 +3738,7 @@ module.exports = {
|
|
|
3581
3738
|
// @ts-check
|
|
3582
3739
|
|
|
3583
3740
|
var _a = __webpack_require__(/*! ../helpers */ "../helpers/helpers.js"), addErrorContext = _a.addErrorContext, filterTokens = _a.filterTokens;
|
|
3584
|
-
var spaceInLinkRe = /\[(?:\s+(?:[^\]]*?)\s*|(?:[^\]]*?)\s+)](
|
|
3741
|
+
var spaceInLinkRe = /\[(?:\s+(?:[^\]]*?)\s*|(?:[^\]]*?)\s+)](?=((?:\([^)]*\))|(?:\[[^\]]*\])))/;
|
|
3585
3742
|
module.exports = {
|
|
3586
3743
|
"names": ["MD039", "no-space-in-links"],
|
|
3587
3744
|
"description": "Spaces inside link text",
|
|
@@ -3610,16 +3767,16 @@ module.exports = {
|
|
|
3610
3767
|
var match = line.slice(lineIndex).match(spaceInLinkRe);
|
|
3611
3768
|
if (match) {
|
|
3612
3769
|
var column = match.index + lineIndex + 1;
|
|
3613
|
-
var
|
|
3614
|
-
range = [column,
|
|
3770
|
+
var length = match[0].length;
|
|
3771
|
+
range = [column, length];
|
|
3615
3772
|
fixInfo = {
|
|
3616
3773
|
"editColumn": column + 1,
|
|
3617
|
-
"deleteCount":
|
|
3774
|
+
"deleteCount": length - 2,
|
|
3618
3775
|
"insertText": linkText.trim()
|
|
3619
3776
|
};
|
|
3620
|
-
lineIndex = column +
|
|
3777
|
+
lineIndex = column + length - 1;
|
|
3621
3778
|
}
|
|
3622
|
-
addErrorContext(onError, lineNumber, "["
|
|
3779
|
+
addErrorContext(onError, lineNumber, "[".concat(linkText, "]"), left, right, range, fixInfo);
|
|
3623
3780
|
}
|
|
3624
3781
|
}
|
|
3625
3782
|
else if ((type === "softbreak") || (type === "hardbreak")) {
|
|
@@ -3682,7 +3839,7 @@ module.exports = {
|
|
|
3682
3839
|
var tag = "h" + level;
|
|
3683
3840
|
var foundFrontMatterTitle = frontMatterHasTitle(params.frontMatterLines, params.config.front_matter_title);
|
|
3684
3841
|
if (!foundFrontMatterTitle) {
|
|
3685
|
-
var htmlHeadingRe_1 = new RegExp("^<h"
|
|
3842
|
+
var htmlHeadingRe_1 = new RegExp("^<h".concat(level, "[ />]"), "i");
|
|
3686
3843
|
params.tokens.every(function (token) {
|
|
3687
3844
|
var isError = false;
|
|
3688
3845
|
if (token.type === "html_block") {
|
|
@@ -3784,7 +3941,6 @@ module.exports = {
|
|
|
3784
3941
|
var matchAny_1 = false;
|
|
3785
3942
|
var hasError_1 = false;
|
|
3786
3943
|
var anyHeadings_1 = false;
|
|
3787
|
-
// eslint-disable-next-line func-style
|
|
3788
3944
|
var getExpected_1 = function () { return requiredHeadings[i_1++] || "[None]"; };
|
|
3789
3945
|
forEachHeading(params, function (heading, content) {
|
|
3790
3946
|
if (!hasError_1) {
|
|
@@ -3837,7 +3993,7 @@ module.exports = {
|
|
|
3837
3993
|
// @ts-check
|
|
3838
3994
|
|
|
3839
3995
|
var _a = __webpack_require__(/*! ../helpers */ "../helpers/helpers.js"), addErrorDetailIf = _a.addErrorDetailIf, bareUrlRe = _a.bareUrlRe, escapeForRegExp = _a.escapeForRegExp, forEachLine = _a.forEachLine, overlapsAnyRange = _a.overlapsAnyRange, linkRe = _a.linkRe, linkReferenceRe = _a.linkReferenceRe;
|
|
3840
|
-
var _b = __webpack_require__(/*! ./cache */ "../lib/cache.js"),
|
|
3996
|
+
var _b = __webpack_require__(/*! ./cache */ "../lib/cache.js"), codeBlockAndSpanRanges = _b.codeBlockAndSpanRanges, lineMetadata = _b.lineMetadata;
|
|
3841
3997
|
module.exports = {
|
|
3842
3998
|
"names": ["MD044", "proper-names"],
|
|
3843
3999
|
"description": "Proper names should have the correct capitalization",
|
|
@@ -3867,13 +4023,13 @@ module.exports = {
|
|
|
3867
4023
|
}
|
|
3868
4024
|
});
|
|
3869
4025
|
if (!includeCodeBlocks) {
|
|
3870
|
-
exclusions.push.apply(exclusions,
|
|
4026
|
+
exclusions.push.apply(exclusions, codeBlockAndSpanRanges());
|
|
3871
4027
|
}
|
|
3872
|
-
var _loop_1 = function (
|
|
3873
|
-
var escapedName = escapeForRegExp(
|
|
3874
|
-
var startNamePattern = /^\W/.test(
|
|
3875
|
-
var endNamePattern = /\W$/.test(
|
|
3876
|
-
var namePattern = "("
|
|
4028
|
+
var _loop_1 = function (name) {
|
|
4029
|
+
var escapedName = escapeForRegExp(name);
|
|
4030
|
+
var startNamePattern = /^\W/.test(name) ? "" : "\\b_*";
|
|
4031
|
+
var endNamePattern = /\W$/.test(name) ? "" : "_*\\b";
|
|
4032
|
+
var namePattern = "(".concat(startNamePattern, ")(").concat(escapedName, ")").concat(endNamePattern);
|
|
3877
4033
|
var nameRe = new RegExp(namePattern, "gi");
|
|
3878
4034
|
forEachLine(lineMetadata(), function (line, lineIndex, inCode, onFence) {
|
|
3879
4035
|
if (includeCodeBlocks || (!inCode && !onFence)) {
|
|
@@ -3881,22 +4037,22 @@ module.exports = {
|
|
|
3881
4037
|
while ((match = nameRe.exec(line)) !== null) {
|
|
3882
4038
|
var leftMatch = match[1], nameMatch = match[2];
|
|
3883
4039
|
var index = match.index + leftMatch.length;
|
|
3884
|
-
var
|
|
3885
|
-
if (!overlapsAnyRange(exclusions, lineIndex, index,
|
|
3886
|
-
addErrorDetailIf(onError, lineIndex + 1,
|
|
4040
|
+
var length = nameMatch.length;
|
|
4041
|
+
if (!overlapsAnyRange(exclusions, lineIndex, index, length)) {
|
|
4042
|
+
addErrorDetailIf(onError, lineIndex + 1, name, nameMatch, null, null, [index + 1, length], {
|
|
3887
4043
|
"editColumn": index + 1,
|
|
3888
|
-
"deleteCount":
|
|
3889
|
-
"insertText":
|
|
4044
|
+
"deleteCount": length,
|
|
4045
|
+
"insertText": name
|
|
3890
4046
|
});
|
|
3891
4047
|
}
|
|
3892
|
-
exclusions.push([lineIndex, index,
|
|
4048
|
+
exclusions.push([lineIndex, index, length]);
|
|
3893
4049
|
}
|
|
3894
4050
|
}
|
|
3895
4051
|
});
|
|
3896
4052
|
};
|
|
3897
4053
|
for (var _i = 0, names_1 = names; _i < names_1.length; _i++) {
|
|
3898
|
-
var
|
|
3899
|
-
_loop_1(
|
|
4054
|
+
var name = names_1[_i];
|
|
4055
|
+
_loop_1(name);
|
|
3900
4056
|
}
|
|
3901
4057
|
}
|
|
3902
4058
|
};
|
|
@@ -3939,7 +4095,7 @@ module.exports = {
|
|
|
3939
4095
|
"use strict";
|
|
3940
4096
|
// @ts-check
|
|
3941
4097
|
|
|
3942
|
-
var addErrorDetailIf = __webpack_require__(/*! ../helpers */ "../helpers/helpers.js").addErrorDetailIf;
|
|
4098
|
+
var addErrorDetailIf = (__webpack_require__(/*! ../helpers */ "../helpers/helpers.js").addErrorDetailIf);
|
|
3943
4099
|
var tokenTypeToStyle = {
|
|
3944
4100
|
"fence": "fenced",
|
|
3945
4101
|
"code_block": "indented"
|
|
@@ -4024,6 +4180,88 @@ module.exports = {
|
|
|
4024
4180
|
};
|
|
4025
4181
|
|
|
4026
4182
|
|
|
4183
|
+
/***/ }),
|
|
4184
|
+
|
|
4185
|
+
/***/ "../lib/md049.js":
|
|
4186
|
+
/*!***********************!*\
|
|
4187
|
+
!*** ../lib/md049.js ***!
|
|
4188
|
+
\***********************/
|
|
4189
|
+
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
|
|
4190
|
+
|
|
4191
|
+
"use strict";
|
|
4192
|
+
// @ts-check
|
|
4193
|
+
|
|
4194
|
+
var _a = __webpack_require__(/*! ../helpers */ "../helpers/helpers.js"), addError = _a.addError, emphasisOrStrongStyleFor = _a.emphasisOrStrongStyleFor, forEachInlineChild = _a.forEachInlineChild, getNextChildToken = _a.getNextChildToken, getRangeAndFixInfoIfFound = _a.getRangeAndFixInfoIfFound;
|
|
4195
|
+
module.exports = {
|
|
4196
|
+
"names": ["MD049", "emphasis-style"],
|
|
4197
|
+
"description": "Emphasis style should be consistent",
|
|
4198
|
+
"tags": ["emphasis"],
|
|
4199
|
+
"function": function MD049(params, onError) {
|
|
4200
|
+
var expectedStyle = String(params.config.style || "consistent");
|
|
4201
|
+
forEachInlineChild(params, "em_open", function (token, parent) {
|
|
4202
|
+
var lineNumber = token.lineNumber, markup = token.markup;
|
|
4203
|
+
var markupStyle = emphasisOrStrongStyleFor(markup);
|
|
4204
|
+
if (expectedStyle === "consistent") {
|
|
4205
|
+
expectedStyle = markupStyle;
|
|
4206
|
+
}
|
|
4207
|
+
if (expectedStyle !== markupStyle) {
|
|
4208
|
+
var rangeAndFixInfo = {};
|
|
4209
|
+
var contentToken = getNextChildToken(parent, token, "text", "em_close");
|
|
4210
|
+
if (contentToken) {
|
|
4211
|
+
var content = contentToken.content;
|
|
4212
|
+
var actual = "".concat(markup).concat(content).concat(markup);
|
|
4213
|
+
var expectedMarkup = (expectedStyle === "asterisk") ? "*" : "_";
|
|
4214
|
+
var expected = "".concat(expectedMarkup).concat(content).concat(expectedMarkup);
|
|
4215
|
+
rangeAndFixInfo = getRangeAndFixInfoIfFound(params.lines, lineNumber - 1, actual, expected);
|
|
4216
|
+
}
|
|
4217
|
+
addError(onError, lineNumber, "Expected: ".concat(expectedStyle, "; Actual: ").concat(markupStyle), null, rangeAndFixInfo.range, rangeAndFixInfo.fixInfo);
|
|
4218
|
+
}
|
|
4219
|
+
});
|
|
4220
|
+
}
|
|
4221
|
+
};
|
|
4222
|
+
|
|
4223
|
+
|
|
4224
|
+
/***/ }),
|
|
4225
|
+
|
|
4226
|
+
/***/ "../lib/md050.js":
|
|
4227
|
+
/*!***********************!*\
|
|
4228
|
+
!*** ../lib/md050.js ***!
|
|
4229
|
+
\***********************/
|
|
4230
|
+
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
|
|
4231
|
+
|
|
4232
|
+
"use strict";
|
|
4233
|
+
// @ts-check
|
|
4234
|
+
|
|
4235
|
+
var _a = __webpack_require__(/*! ../helpers */ "../helpers/helpers.js"), addError = _a.addError, emphasisOrStrongStyleFor = _a.emphasisOrStrongStyleFor, forEachInlineChild = _a.forEachInlineChild, getNextChildToken = _a.getNextChildToken, getRangeAndFixInfoIfFound = _a.getRangeAndFixInfoIfFound;
|
|
4236
|
+
module.exports = {
|
|
4237
|
+
"names": ["MD050", "strong-style"],
|
|
4238
|
+
"description": "Strong style should be consistent",
|
|
4239
|
+
"tags": ["emphasis"],
|
|
4240
|
+
"function": function MD050(params, onError) {
|
|
4241
|
+
var expectedStyle = String(params.config.style || "consistent");
|
|
4242
|
+
forEachInlineChild(params, "strong_open", function (token, parent) {
|
|
4243
|
+
var lineNumber = token.lineNumber, markup = token.markup;
|
|
4244
|
+
var markupStyle = emphasisOrStrongStyleFor(markup);
|
|
4245
|
+
if (expectedStyle === "consistent") {
|
|
4246
|
+
expectedStyle = markupStyle;
|
|
4247
|
+
}
|
|
4248
|
+
if (expectedStyle !== markupStyle) {
|
|
4249
|
+
var rangeAndFixInfo = {};
|
|
4250
|
+
var contentToken = getNextChildToken(parent, token, "text", "strong_close");
|
|
4251
|
+
if (contentToken) {
|
|
4252
|
+
var content = contentToken.content;
|
|
4253
|
+
var actual = "".concat(markup).concat(content).concat(markup);
|
|
4254
|
+
var expectedMarkup = (expectedStyle === "asterisk") ? "**" : "__";
|
|
4255
|
+
var expected = "".concat(expectedMarkup).concat(content).concat(expectedMarkup);
|
|
4256
|
+
rangeAndFixInfo = getRangeAndFixInfoIfFound(params.lines, lineNumber - 1, actual, expected);
|
|
4257
|
+
}
|
|
4258
|
+
addError(onError, lineNumber, "Expected: ".concat(expectedStyle, "; Actual: ").concat(markupStyle), null, rangeAndFixInfo.range, rangeAndFixInfo.fixInfo);
|
|
4259
|
+
}
|
|
4260
|
+
});
|
|
4261
|
+
}
|
|
4262
|
+
};
|
|
4263
|
+
|
|
4264
|
+
|
|
4027
4265
|
/***/ }),
|
|
4028
4266
|
|
|
4029
4267
|
/***/ "../lib/rules.js":
|
|
@@ -4035,9 +4273,7 @@ module.exports = {
|
|
|
4035
4273
|
"use strict";
|
|
4036
4274
|
// @ts-check
|
|
4037
4275
|
|
|
4038
|
-
var
|
|
4039
|
-
var homepage = packageJson.homepage;
|
|
4040
|
-
var version = packageJson.version;
|
|
4276
|
+
var _a = __webpack_require__(/*! ./constants */ "../lib/constants.js"), homepage = _a.homepage, version = _a.version;
|
|
4041
4277
|
var rules = [
|
|
4042
4278
|
__webpack_require__(/*! ./md001 */ "../lib/md001.js"),
|
|
4043
4279
|
__webpack_require__(/*! ./md002 */ "../lib/md002.js"),
|
|
@@ -4082,13 +4318,15 @@ var rules = [
|
|
|
4082
4318
|
__webpack_require__(/*! ./md045 */ "../lib/md045.js"),
|
|
4083
4319
|
__webpack_require__(/*! ./md046 */ "../lib/md046.js"),
|
|
4084
4320
|
__webpack_require__(/*! ./md047 */ "../lib/md047.js"),
|
|
4085
|
-
__webpack_require__(/*! ./md048 */ "../lib/md048.js")
|
|
4321
|
+
__webpack_require__(/*! ./md048 */ "../lib/md048.js"),
|
|
4322
|
+
__webpack_require__(/*! ./md049 */ "../lib/md049.js"),
|
|
4323
|
+
__webpack_require__(/*! ./md050 */ "../lib/md050.js")
|
|
4086
4324
|
];
|
|
4087
4325
|
rules.forEach(function (rule) {
|
|
4088
4326
|
var name = rule.names[0].toLowerCase();
|
|
4089
4327
|
// eslint-disable-next-line dot-notation
|
|
4090
4328
|
rule["information"] =
|
|
4091
|
-
new URL(homepage
|
|
4329
|
+
new URL("".concat(homepage, "/blob/v").concat(version, "/doc/Rules.md#").concat(name));
|
|
4092
4330
|
});
|
|
4093
4331
|
module.exports = rules;
|
|
4094
4332
|
|
|
@@ -4106,16 +4344,6 @@ module.exports = markdownit;
|
|
|
4106
4344
|
|
|
4107
4345
|
/***/ }),
|
|
4108
4346
|
|
|
4109
|
-
/***/ "?591e":
|
|
4110
|
-
/*!********************!*\
|
|
4111
|
-
!*** os (ignored) ***!
|
|
4112
|
-
\********************/
|
|
4113
|
-
/***/ (() => {
|
|
4114
|
-
|
|
4115
|
-
/* (ignored) */
|
|
4116
|
-
|
|
4117
|
-
/***/ }),
|
|
4118
|
-
|
|
4119
4347
|
/***/ "?ec0a":
|
|
4120
4348
|
/*!********************!*\
|
|
4121
4349
|
!*** fs (ignored) ***!
|
|
@@ -4144,17 +4372,6 @@ module.exports = markdownit;
|
|
|
4144
4372
|
|
|
4145
4373
|
/* (ignored) */
|
|
4146
4374
|
|
|
4147
|
-
/***/ }),
|
|
4148
|
-
|
|
4149
|
-
/***/ "../package.json":
|
|
4150
|
-
/*!***********************!*\
|
|
4151
|
-
!*** ../package.json ***!
|
|
4152
|
-
\***********************/
|
|
4153
|
-
/***/ ((module) => {
|
|
4154
|
-
|
|
4155
|
-
"use strict";
|
|
4156
|
-
module.exports = JSON.parse('{"name":"markdownlint","version":"0.24.0","description":"A Node.js style checker and lint tool for Markdown/CommonMark files.","main":"lib/markdownlint.js","types":"lib/markdownlint.d.ts","author":"David Anson (https://dlaa.me/)","license":"MIT","homepage":"https://github.com/DavidAnson/markdownlint","repository":{"type":"git","url":"https://github.com/DavidAnson/markdownlint.git"},"bugs":"https://github.com/DavidAnson/markdownlint/issues","scripts":{"build-config":"npm run build-config-schema && npm run build-config-example","build-config-example":"node schema/build-config-example.js","build-config-schema":"node schema/build-config-schema.js","build-declaration":"tsc --allowJs --declaration --emitDeclarationOnly --resolveJsonModule lib/markdownlint.js && rimraf \'lib/{c,md,r}*.d.ts\' \'helpers/*.d.ts\'","build-demo":"cpy node_modules/markdown-it/dist/markdown-it.min.js demo && cd demo && rimraf markdownlint-browser.* && webpack --no-stats","build-example":"npm install --no-save --ignore-scripts grunt grunt-cli gulp through2","ci":"npm-run-all --continue-on-error --parallel test-cover lint declaration build-config build-demo && git diff --exit-code","clean-test-repos":"rimraf test-repos","clone-test-repos-dotnet-docs":"cd test-repos && git clone https://github.com/dotnet/docs dotnet-docs --depth 1 --no-tags --quiet","clone-test-repos-eslint-eslint":"cd test-repos && git clone https://github.com/eslint/eslint eslint-eslint --depth 1 --no-tags --quiet","clone-test-repos-mkdocs-mkdocs":"cd test-repos && git clone https://github.com/mkdocs/mkdocs mkdocs-mkdocs --depth 1 --no-tags --quiet","clone-test-repos-mochajs-mocha":"cd test-repos && git clone https://github.com/mochajs/mocha mochajs-mocha --depth 1 --no-tags --quiet","clone-test-repos-pi-hole-docs":"cd test-repos && git clone https://github.com/pi-hole/docs pi-hole-docs --depth 1 --no-tags --quiet","clone-test-repos-v8-v8-dev":"cd test-repos && git clone https://github.com/v8/v8.dev v8-v8-dev --depth 1 --no-tags --quiet","clone-test-repos-webhintio-hint":"cd test-repos && git clone https://github.com/webhintio/hint webhintio-hint --depth 1 --no-tags --quiet","clone-test-repos-webpack-webpack-js-org":"cd test-repos && git clone https://github.com/webpack/webpack.js.org webpack-webpack-js-org --depth 1 --no-tags --quiet","clone-test-repos":"mkdir test-repos && cd test-repos && npm run clone-test-repos-eslint-eslint && npm run clone-test-repos-mkdocs-mkdocs && npm run clone-test-repos-mochajs-mocha && npm run clone-test-repos-pi-hole-docs && npm run clone-test-repos-webhintio-hint && npm run clone-test-repos-webpack-webpack-js-org","clone-test-repos-large":"npm run clone-test-repos && cd test-repos && npm run clone-test-repos-dotnet-docs && npm run clone-test-repos-v8-v8-dev","declaration":"npm run build-declaration && npm run test-declaration","example":"cd example && node standalone.js && grunt markdownlint --force && gulp markdownlint","lint":"eslint --max-warnings 0 .","lint-test-repos":"ava --timeout=5m test/markdownlint-test-repos.js","test":"ava test/markdownlint-test.js test/markdownlint-test-custom-rules.js test/markdownlint-test-helpers.js test/markdownlint-test-result-object.js test/markdownlint-test-scenarios.js","test-cover":"c8 --check-coverage --branches 100 --functions 100 --lines 100 --statements 100 npm test","test-declaration":"cd example/typescript && tsc && node type-check.js","test-extra":"ava --timeout=5m test/markdownlint-test-extra.js"},"engines":{"node":">=10"},"dependencies":{"markdown-it":"12.2.0"},"devDependencies":{"ava":"~3.15.0","c8":"~7.8.0","cpy-cli":"~3.1.1","eslint":"~7.32.0","eslint-plugin-jsdoc":"~36.0.7","eslint-plugin-node":"~11.1.0","eslint-plugin-unicorn":"~35.0.0","globby":"~11.0.4","js-yaml":"~4.1.0","markdown-it-for-inline":"~0.1.1","markdown-it-sub":"~1.0.0","markdown-it-sup":"~1.0.0","markdown-it-texmath":"~0.9.1","markdownlint-rule-helpers":"~0.14.0","npm-run-all":"~4.1.5","rimraf":"~3.0.2","strip-json-comments":"~3.1.1","toml":"~3.0.0","ts-loader":"~9.2.5","tv4":"~1.3.0","typescript":"~4.3.5","webpack":"~5.51.1","webpack-cli":"~4.8.0"},"keywords":["markdown","lint","md","CommonMark","markdownlint"]}');
|
|
4157
|
-
|
|
4158
4375
|
/***/ })
|
|
4159
4376
|
|
|
4160
4377
|
/******/ });
|