markdownlint 0.40.0 → 0.41.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 +9 -0
- package/CONTRIBUTING.md +1 -1
- package/README.md +13 -25
- package/doc/CustomRules.md +1 -1
- package/doc/Rules.md +69 -25
- package/doc/md001.md +1 -1
- package/doc/md011.md +1 -1
- package/doc/md022.md +15 -0
- package/doc/md025.md +1 -1
- package/doc/md026.md +1 -1
- package/doc/md028.md +13 -9
- package/doc/md034.md +1 -1
- package/doc/md035.md +12 -5
- package/doc/md041.md +2 -2
- package/doc/md042.md +6 -0
- package/doc/md045.md +1 -1
- package/doc/md060.md +15 -3
- package/helpers/README.md +4 -4
- package/helpers/helpers.cjs +45 -46
- package/helpers/micromark-helpers.cjs +4 -3
- package/helpers/package.json +2 -2
- package/helpers/shared.cjs +1 -1
- package/lib/configuration-strict.d.ts +116 -108
- package/lib/constants.mjs +2 -2
- package/lib/exports.d.mts +1 -0
- package/lib/exports.mjs +1 -0
- package/lib/markdownit.cjs +8 -7
- package/lib/markdownlint.d.mts +56 -41
- package/lib/markdownlint.mjs +35 -103
- package/lib/md022.mjs +14 -11
- package/lib/md029.mjs +3 -3
- package/lib/md036.mjs +1 -0
- package/lib/md051.mjs +2 -1
- package/lib/md060.mjs +47 -8
- package/lib/micromark-parse.mjs +19 -4
- package/lib/resolve-module.cjs +3 -3
- package/lib/resolve-module.d.cts +1 -1
- package/package.json +35 -38
- package/schema/.markdownlint.jsonc +55 -53
- package/schema/.markdownlint.yaml +55 -53
- package/schema/markdownlint-config-schema-strict.json +120 -110
- package/schema/markdownlint-config-schema.json +120 -110
package/helpers/helpers.cjs
CHANGED
|
@@ -4,9 +4,9 @@
|
|
|
4
4
|
|
|
5
5
|
const micromark = require("./micromark-helpers.cjs");
|
|
6
6
|
|
|
7
|
-
const {
|
|
7
|
+
const { newlineRe, nextLinesRe } = require("./shared.cjs");
|
|
8
8
|
|
|
9
|
-
module.exports.newLineRe =
|
|
9
|
+
module.exports.newLineRe = newlineRe;
|
|
10
10
|
module.exports.nextLinesRe = nextLinesRe;
|
|
11
11
|
|
|
12
12
|
/** @typedef {import("../lib/exports.mjs").RuleOnError} RuleOnError */
|
|
@@ -311,7 +311,7 @@ module.exports.addErrorDetailIf = addErrorDetailIf;
|
|
|
311
311
|
*/
|
|
312
312
|
function addErrorContext(onError, lineNumber, context, start, end, range, fixInfo) {
|
|
313
313
|
// Normalize new line characters so Linux and Windows trim consistently
|
|
314
|
-
context = ellipsify(context.replace(
|
|
314
|
+
context = ellipsify(context.replace(newlineRe, "\n"), start, end);
|
|
315
315
|
addError(onError, lineNumber, undefined, context, range, fixInfo);
|
|
316
316
|
}
|
|
317
317
|
module.exports.addErrorContext = addErrorContext;
|
|
@@ -438,59 +438,59 @@ function getReferenceLinkImageData(tokens) {
|
|
|
438
438
|
case "gfmFootnoteDefinitionLabelString":
|
|
439
439
|
labelPrefix = "^";
|
|
440
440
|
case "definitionLabelString": // eslint-disable-line no-fallthrough
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
}
|
|
441
|
+
{
|
|
442
|
+
// definitions and definitionLineIndices
|
|
443
|
+
const reference = normalizeReference(`${labelPrefix}${token.text}`);
|
|
444
|
+
if (definitions.has(reference)) {
|
|
445
|
+
duplicateDefinitions.push([ reference, token.startLine - 1 ]);
|
|
446
|
+
} else {
|
|
447
|
+
const parent =
|
|
448
|
+
micromark.getParentOfType(token, [ "definition" ]);
|
|
449
|
+
const destinationString = parent &&
|
|
450
|
+
micromark.getDescendantsByType(parent, [ "definitionDestination", "definitionDestinationRaw", "definitionDestinationString" ])[0]?.text;
|
|
451
|
+
definitions.set(
|
|
452
|
+
reference,
|
|
453
|
+
[ token.startLine - 1, destinationString || "" ]
|
|
454
|
+
);
|
|
456
455
|
}
|
|
457
456
|
break;
|
|
457
|
+
}
|
|
458
458
|
case "gfmFootnoteCall":
|
|
459
459
|
case "image":
|
|
460
460
|
case "link":
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
}
|
|
477
|
-
}
|
|
478
|
-
// Track link (handle shortcuts separately due to ambiguity in "text [text] text")
|
|
479
|
-
if (isShortcut || isFullOrCollapsed) {
|
|
480
|
-
addReferenceToDictionary(token, getText(referenceString) || label, isShortcut);
|
|
461
|
+
{
|
|
462
|
+
// Identify if shortcut or full/collapsed
|
|
463
|
+
let isShortcut = (token.children.length === 1);
|
|
464
|
+
const isFullOrCollapsed = (token.children.length === 2) && !token.children.some((t) => t.type === "resource");
|
|
465
|
+
const [ labelText ] = micromark.getDescendantsByType(token, [ "label", "labelText" ]);
|
|
466
|
+
const [ referenceString ] = micromark.getDescendantsByType(token, [ "reference", "referenceString" ]);
|
|
467
|
+
let label = getText(labelText);
|
|
468
|
+
// Identify if footnote
|
|
469
|
+
if (!isShortcut && !isFullOrCollapsed) {
|
|
470
|
+
const [ footnoteCallMarker, footnoteCallString ] = token.children.filter(
|
|
471
|
+
(t) => [ "gfmFootnoteCallMarker", "gfmFootnoteCallString" ].includes(t.type)
|
|
472
|
+
);
|
|
473
|
+
if (footnoteCallMarker && footnoteCallString) {
|
|
474
|
+
label = `${footnoteCallMarker.text}${footnoteCallString.text}`;
|
|
475
|
+
isShortcut = true;
|
|
481
476
|
}
|
|
482
477
|
}
|
|
478
|
+
// Track link (handle shortcuts separately due to ambiguity in "text [text] text")
|
|
479
|
+
if (isShortcut || isFullOrCollapsed) {
|
|
480
|
+
addReferenceToDictionary(token, getText(referenceString) || label, isShortcut);
|
|
481
|
+
}
|
|
483
482
|
break;
|
|
483
|
+
}
|
|
484
484
|
case "undefinedReferenceCollapsed":
|
|
485
485
|
case "undefinedReferenceFull":
|
|
486
486
|
case "undefinedReferenceShortcut":
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
}
|
|
487
|
+
{
|
|
488
|
+
const undefinedReference = micromark.getDescendantsByType(token, [ "undefinedReference" ])[0];
|
|
489
|
+
const label = undefinedReference.children.map((t) => t.text).join("");
|
|
490
|
+
const isShortcut = (token.type === "undefinedReferenceShortcut");
|
|
491
|
+
addReferenceToDictionary(token, label, isShortcut);
|
|
493
492
|
break;
|
|
493
|
+
}
|
|
494
494
|
}
|
|
495
495
|
}
|
|
496
496
|
return {
|
|
@@ -514,7 +514,7 @@ function getPreferredLineEnding(input, os) {
|
|
|
514
514
|
let cr = 0;
|
|
515
515
|
let lf = 0;
|
|
516
516
|
let crlf = 0;
|
|
517
|
-
const endings = input.match(
|
|
517
|
+
const endings = input.match(newlineRe) || [];
|
|
518
518
|
for (const ending of endings) {
|
|
519
519
|
// eslint-disable-next-line default-case
|
|
520
520
|
switch (ending) {
|
|
@@ -630,7 +630,6 @@ function convertLintErrorsVersion2To0(errors) {
|
|
|
630
630
|
function copyAndTransformResults(results, transform) {
|
|
631
631
|
/** @type {Object.<string, LintErrors>} */
|
|
632
632
|
const newResults = {};
|
|
633
|
-
Object.defineProperty(newResults, "toString", { "value": results.toString });
|
|
634
633
|
for (const key of Object.keys(results)) {
|
|
635
634
|
const arr = results[key].map((r) => ({ ...r }));
|
|
636
635
|
newResults[key] = transform(arr);
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
"use strict";
|
|
4
4
|
|
|
5
|
-
const { flatTokensSymbol, htmlFlowSymbol,
|
|
5
|
+
const { flatTokensSymbol, htmlFlowSymbol, newlineRe } = require("./shared.cjs");
|
|
6
6
|
|
|
7
7
|
// eslint-disable-next-line jsdoc/valid-types
|
|
8
8
|
/** @typedef {import("micromark-util-types", { with: { "resolution-mode": "import" } }).TokenType} TokenType */
|
|
@@ -152,7 +152,6 @@ function getBlockQuotePrefixText(tokens, lineNumber, count = 1) {
|
|
|
152
152
|
.map((prefix) => prefix.text)
|
|
153
153
|
.join("")
|
|
154
154
|
.trimEnd()
|
|
155
|
-
// eslint-disable-next-line unicorn/prefer-spread
|
|
156
155
|
.concat("\n")
|
|
157
156
|
.repeat(count);
|
|
158
157
|
};
|
|
@@ -224,7 +223,7 @@ function getHeadingText(heading) {
|
|
|
224
223
|
.flatMap((descendant) => descendant.children.filter((child) => child.type !== "htmlText"))
|
|
225
224
|
.map((data) => data.text)
|
|
226
225
|
.join("")
|
|
227
|
-
.replace(
|
|
226
|
+
.replace(newlineRe, " ");
|
|
228
227
|
}
|
|
229
228
|
|
|
230
229
|
/**
|
|
@@ -285,7 +284,9 @@ function isDocfxTab(heading) {
|
|
|
285
284
|
// See https://dotnet.github.io/docfx/docs/markdown.html?tabs=linux%2Cdotnet#tabs
|
|
286
285
|
if (heading?.type === "atxHeading") {
|
|
287
286
|
const headingTexts = getDescendantsByType(heading, [ "atxHeadingText" ]);
|
|
287
|
+
// eslint-disable-next-line unicorn/better-dom-traversing
|
|
288
288
|
if ((headingTexts.length === 1) && (headingTexts[0].children.length === 1) && (headingTexts[0].children[0].type === "link")) {
|
|
289
|
+
// eslint-disable-next-line unicorn/better-dom-traversing
|
|
289
290
|
const resourceDestinationStrings = filterByTypes(headingTexts[0].children[0].children, [ "resourceDestinationString" ]);
|
|
290
291
|
return (resourceDestinationStrings.length === 1) && docfxTabSyntaxRe.test(resourceDestinationStrings[0].text);
|
|
291
292
|
}
|
package/helpers/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "markdownlint-rule-helpers",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.31.0",
|
|
4
4
|
"description": "A collection of markdownlint helper functions for custom rules",
|
|
5
5
|
"main": "./helpers.cjs",
|
|
6
6
|
"exports": {
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
"bugs": "https://github.com/DavidAnson/markdownlint/issues",
|
|
18
18
|
"funding": "https://github.com/sponsors/DavidAnson",
|
|
19
19
|
"engines": {
|
|
20
|
-
"node": ">=
|
|
20
|
+
"node": ">=22"
|
|
21
21
|
},
|
|
22
22
|
"keywords": [
|
|
23
23
|
"markdownlint",
|
package/helpers/shared.cjs
CHANGED
|
@@ -10,7 +10,7 @@ module.exports.htmlFlowSymbol = Symbol("html-flow");
|
|
|
10
10
|
|
|
11
11
|
// Regular expression for matching common newline characters
|
|
12
12
|
// See NEWLINES_RE in markdown-it/lib/rules_core/normalize.js
|
|
13
|
-
module.exports.
|
|
13
|
+
module.exports.newlineRe = /\r\n?|\n/g;
|
|
14
14
|
|
|
15
15
|
// Regular expression for matching next lines
|
|
16
16
|
module.exports.nextLinesRe = /[\r\n][\s\S]*$/;
|