@storm-software/markdownlint 0.5.0 β 0.5.1
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 +7 -0
- package/index.js +160 -145
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
package/index.js
CHANGED
|
@@ -5509,165 +5509,180 @@ var require_lodash = __commonJS({
|
|
|
5509
5509
|
}
|
|
5510
5510
|
});
|
|
5511
5511
|
|
|
5512
|
-
// packages/markdownlint/src/index.ts
|
|
5513
|
-
var src_exports = {};
|
|
5514
|
-
__export(src_exports, {
|
|
5515
|
-
default: () => src_default,
|
|
5516
|
-
init: () => init
|
|
5517
|
-
});
|
|
5518
|
-
module.exports = __toCommonJS(src_exports);
|
|
5519
|
-
var import_lodash = __toESM(require_lodash());
|
|
5520
|
-
|
|
5521
5512
|
// packages/markdownlint/src/rules/no-default-alt-text.ts
|
|
5522
|
-
var
|
|
5523
|
-
|
|
5524
|
-
var
|
|
5525
|
-
var
|
|
5526
|
-
var
|
|
5527
|
-
var
|
|
5528
|
-
|
|
5529
|
-
|
|
5530
|
-
|
|
5531
|
-
|
|
5532
|
-
|
|
5533
|
-
|
|
5534
|
-
|
|
5535
|
-
|
|
5536
|
-
(
|
|
5537
|
-
|
|
5538
|
-
|
|
5539
|
-
|
|
5540
|
-
|
|
5541
|
-
|
|
5542
|
-
|
|
5543
|
-
|
|
5544
|
-
|
|
5545
|
-
|
|
5546
|
-
|
|
5547
|
-
|
|
5548
|
-
|
|
5549
|
-
|
|
5550
|
-
|
|
5551
|
-
|
|
5552
|
-
|
|
5553
|
-
|
|
5554
|
-
|
|
5555
|
-
|
|
5556
|
-
|
|
5557
|
-
|
|
5558
|
-
|
|
5559
|
-
|
|
5560
|
-
|
|
5561
|
-
|
|
5562
|
-
|
|
5563
|
-
|
|
5564
|
-
|
|
5565
|
-
|
|
5566
|
-
|
|
5513
|
+
var require_no_default_alt_text = __commonJS({
|
|
5514
|
+
"packages/markdownlint/src/rules/no-default-alt-text.ts"(exports2, module2) {
|
|
5515
|
+
var defaultScreenshotRegex = `(?:screen|clean) ?(?:shot|cast) \\d{4}-\\d{2}-\\d{2}[^'"\\]]*`;
|
|
5516
|
+
var imageRegex = "image";
|
|
5517
|
+
var combinedRegex = `(${[defaultScreenshotRegex, imageRegex].join("|")})`;
|
|
5518
|
+
var markdownAltRegex = new RegExp(`!\\[${combinedRegex}\\]\\(.*\\)`, "gid");
|
|
5519
|
+
var htmlAltRegex = new RegExp(`alt=["']${combinedRegex}["']`, "gid");
|
|
5520
|
+
module2.exports = {
|
|
5521
|
+
names: ["SS001", "no-default-alt-text"],
|
|
5522
|
+
description: "Images should have meaningful alternative text (alt text)",
|
|
5523
|
+
information: new URL(
|
|
5524
|
+
"https://github.com/github/markdownlint-github/blob/main/docs/rules/GH001-no-default-alt-text.md"
|
|
5525
|
+
),
|
|
5526
|
+
tags: ["accessibility", "images"],
|
|
5527
|
+
function: function SS001(params, onError) {
|
|
5528
|
+
const htmlTagsWithImages = params.parsers.markdownit.tokens.filter(
|
|
5529
|
+
(token) => {
|
|
5530
|
+
return token.type === "html_block" && token.content.includes("<img") || token.type === "inline" && token.content.includes("<img") && token.children.some((child) => child.type === "html_inline");
|
|
5531
|
+
}
|
|
5532
|
+
);
|
|
5533
|
+
const inlineImages = params.parsers.markdownit.tokens.filter(
|
|
5534
|
+
(token) => token.type === "inline" && token.children.some((child) => child.type === "image")
|
|
5535
|
+
);
|
|
5536
|
+
for (const token of [...htmlTagsWithImages, ...inlineImages]) {
|
|
5537
|
+
const lineRange = token.map;
|
|
5538
|
+
const lineNumber = token.lineNumber;
|
|
5539
|
+
const lines = params.lines.slice(lineRange[0], lineRange[1]);
|
|
5540
|
+
for (let i = 0; i < lines.length; i++) {
|
|
5541
|
+
const line = lines[i];
|
|
5542
|
+
let matches;
|
|
5543
|
+
if (token.type === "inline") {
|
|
5544
|
+
if (token.children.some((child) => child.type === "html_inline")) {
|
|
5545
|
+
matches = line.matchAll(htmlAltRegex);
|
|
5546
|
+
} else {
|
|
5547
|
+
matches = line.matchAll(markdownAltRegex);
|
|
5548
|
+
}
|
|
5549
|
+
} else {
|
|
5550
|
+
matches = line.matchAll(htmlAltRegex);
|
|
5551
|
+
}
|
|
5552
|
+
for (const match of matches) {
|
|
5553
|
+
const altText = match[1];
|
|
5554
|
+
const [startIndex] = match.indices[1];
|
|
5555
|
+
onError({
|
|
5556
|
+
lineNumber: lineNumber + i,
|
|
5557
|
+
range: [startIndex + 1, altText.length],
|
|
5558
|
+
detail: `Flagged alt: ${altText}`
|
|
5559
|
+
});
|
|
5560
|
+
}
|
|
5561
|
+
}
|
|
5567
5562
|
}
|
|
5568
5563
|
}
|
|
5569
|
-
}
|
|
5564
|
+
};
|
|
5570
5565
|
}
|
|
5571
|
-
};
|
|
5566
|
+
});
|
|
5572
5567
|
|
|
5573
|
-
// packages/markdownlint/src/rules/no-
|
|
5574
|
-
|
|
5575
|
-
|
|
5576
|
-
|
|
5577
|
-
|
|
5578
|
-
|
|
5579
|
-
|
|
5580
|
-
|
|
5581
|
-
|
|
5582
|
-
|
|
5583
|
-
|
|
5584
|
-
|
|
5585
|
-
|
|
5586
|
-
|
|
5587
|
-
|
|
5588
|
-
|
|
5589
|
-
|
|
5590
|
-
|
|
5591
|
-
|
|
5592
|
-
|
|
5593
|
-
|
|
5594
|
-
|
|
5595
|
-
|
|
5596
|
-
|
|
5597
|
-
|
|
5598
|
-
|
|
5599
|
-
|
|
5600
|
-
|
|
5601
|
-
|
|
5602
|
-
|
|
5603
|
-
|
|
5604
|
-
|
|
5605
|
-
|
|
5606
|
-
|
|
5607
|
-
|
|
5608
|
-
|
|
5609
|
-
|
|
5610
|
-
|
|
5611
|
-
linkText = "";
|
|
5612
|
-
} else if (type === "link_close") {
|
|
5613
|
-
inLink = false;
|
|
5614
|
-
if (bannedLinkTexts.includes(stripAndDowncaseText(linkText))) {
|
|
5615
|
-
onError({
|
|
5616
|
-
lineNumber: child.lineNumber,
|
|
5617
|
-
detail: `For link: ${linkText}`
|
|
5618
|
-
});
|
|
5568
|
+
// packages/markdownlint/src/rules/no-empty-alt-text.ts
|
|
5569
|
+
var require_no_empty_alt_text = __commonJS({
|
|
5570
|
+
"packages/markdownlint/src/rules/no-empty-alt-text.ts"(exports2, module2) {
|
|
5571
|
+
module2.exports = {
|
|
5572
|
+
names: ["SS003", "no-empty-alt-text"],
|
|
5573
|
+
description: "Please provide an alternative text for the image.",
|
|
5574
|
+
information: new URL(
|
|
5575
|
+
"https://github.com/github/markdownlint-github/blob/main/docs/rules/GH003-no-empty-alt-text.md"
|
|
5576
|
+
),
|
|
5577
|
+
tags: ["accessibility", "images"],
|
|
5578
|
+
function: function SS003(params, onError) {
|
|
5579
|
+
const htmlTagsWithImages = params.parsers.markdownit.tokens.filter(
|
|
5580
|
+
(token) => {
|
|
5581
|
+
return token.type === "html_block" && token.content.includes("<img") || token.type === "inline" && token.content.includes("<img") && token.children.some((child) => child.type === "html_inline");
|
|
5582
|
+
}
|
|
5583
|
+
);
|
|
5584
|
+
const ImageRegex = new RegExp(/<img(.*?)>/, "gid");
|
|
5585
|
+
const htmlEmptyAltRegex = new RegExp(/alt=['"]['"]/, "gid");
|
|
5586
|
+
for (const token of htmlTagsWithImages) {
|
|
5587
|
+
const lineRange = token.map;
|
|
5588
|
+
const lineNumber = token.lineNumber;
|
|
5589
|
+
const lines = params.lines.slice(lineRange[0], lineRange[1]);
|
|
5590
|
+
for (const [i, line] of lines.entries()) {
|
|
5591
|
+
const imageTags = line.matchAll(ImageRegex);
|
|
5592
|
+
for (const imageTag of imageTags) {
|
|
5593
|
+
const imageTagIndex = imageTag.indices[0][0];
|
|
5594
|
+
const emptyAltMatches = [
|
|
5595
|
+
...imageTag[0].matchAll(htmlEmptyAltRegex)
|
|
5596
|
+
][0];
|
|
5597
|
+
if (emptyAltMatches) {
|
|
5598
|
+
const matchingContent = emptyAltMatches[0];
|
|
5599
|
+
const startIndex = emptyAltMatches.indices[0][0];
|
|
5600
|
+
onError({
|
|
5601
|
+
lineNumber: lineNumber + i,
|
|
5602
|
+
range: [imageTagIndex + startIndex + 1, matchingContent.length]
|
|
5603
|
+
});
|
|
5604
|
+
}
|
|
5605
|
+
}
|
|
5619
5606
|
}
|
|
5620
|
-
} else if (inLink) {
|
|
5621
|
-
linkText += content;
|
|
5622
5607
|
}
|
|
5623
5608
|
}
|
|
5624
|
-
}
|
|
5609
|
+
};
|
|
5625
5610
|
}
|
|
5626
|
-
};
|
|
5611
|
+
});
|
|
5627
5612
|
|
|
5628
|
-
// packages/markdownlint/src/rules/no-
|
|
5629
|
-
var
|
|
5630
|
-
|
|
5631
|
-
|
|
5632
|
-
|
|
5633
|
-
|
|
5634
|
-
|
|
5635
|
-
|
|
5636
|
-
|
|
5637
|
-
|
|
5638
|
-
|
|
5639
|
-
|
|
5640
|
-
|
|
5641
|
-
|
|
5642
|
-
|
|
5643
|
-
|
|
5644
|
-
|
|
5645
|
-
|
|
5646
|
-
|
|
5647
|
-
|
|
5648
|
-
|
|
5649
|
-
|
|
5650
|
-
|
|
5651
|
-
|
|
5652
|
-
|
|
5653
|
-
|
|
5654
|
-
|
|
5655
|
-
|
|
5656
|
-
|
|
5657
|
-
|
|
5658
|
-
|
|
5659
|
-
|
|
5660
|
-
|
|
5661
|
-
|
|
5613
|
+
// packages/markdownlint/src/rules/no-generic-link-text.ts
|
|
5614
|
+
var require_no_generic_link_text = __commonJS({
|
|
5615
|
+
"packages/markdownlint/src/rules/no-generic-link-text.ts"(exports2, module2) {
|
|
5616
|
+
function stripAndDowncaseText(text) {
|
|
5617
|
+
return text.toLowerCase().replace(/[.,/#!$%^&*;:{}=\-_`~()]/g, "").replace(/\s+/g, " ").trim();
|
|
5618
|
+
}
|
|
5619
|
+
var bannedLinkText = [
|
|
5620
|
+
"read more",
|
|
5621
|
+
"learn more",
|
|
5622
|
+
"more",
|
|
5623
|
+
"here",
|
|
5624
|
+
"click here",
|
|
5625
|
+
"link"
|
|
5626
|
+
];
|
|
5627
|
+
module2.exports = {
|
|
5628
|
+
names: ["SS002", "no-generic-link-text"],
|
|
5629
|
+
description: "Avoid using generic link text like `Learn more` or `Click here`",
|
|
5630
|
+
information: new URL(
|
|
5631
|
+
"https://github.com/github/markdownlint-github/blob/main/docs/rules/GH002-no-generic-link-text.md"
|
|
5632
|
+
),
|
|
5633
|
+
tags: ["accessibility", "links"],
|
|
5634
|
+
function: function SS002(params, onError) {
|
|
5635
|
+
let bannedLinkTexts = bannedLinkText.concat(
|
|
5636
|
+
params.config.additional_banned_texts || []
|
|
5637
|
+
);
|
|
5638
|
+
const exceptions = params.config.exceptions || [];
|
|
5639
|
+
if (exceptions.length > 0) {
|
|
5640
|
+
bannedLinkTexts = bannedLinkTexts.filter(
|
|
5641
|
+
(text) => !exceptions.includes(text)
|
|
5642
|
+
);
|
|
5643
|
+
}
|
|
5644
|
+
const inlineTokens = params.tokens.filter((t) => t.type === "inline");
|
|
5645
|
+
for (const token of inlineTokens) {
|
|
5646
|
+
const { children } = token;
|
|
5647
|
+
let inLink = false;
|
|
5648
|
+
let linkText = "";
|
|
5649
|
+
for (const child of children) {
|
|
5650
|
+
const { content, type } = child;
|
|
5651
|
+
if (type === "link_open") {
|
|
5652
|
+
inLink = true;
|
|
5653
|
+
linkText = "";
|
|
5654
|
+
} else if (type === "link_close") {
|
|
5655
|
+
inLink = false;
|
|
5656
|
+
if (bannedLinkTexts.includes(stripAndDowncaseText(linkText))) {
|
|
5657
|
+
onError({
|
|
5658
|
+
lineNumber: child.lineNumber,
|
|
5659
|
+
detail: `For link: ${linkText}`
|
|
5660
|
+
});
|
|
5661
|
+
}
|
|
5662
|
+
} else if (inLink) {
|
|
5663
|
+
linkText += content;
|
|
5664
|
+
}
|
|
5662
5665
|
}
|
|
5663
5666
|
}
|
|
5664
5667
|
}
|
|
5665
|
-
}
|
|
5668
|
+
};
|
|
5666
5669
|
}
|
|
5667
|
-
};
|
|
5670
|
+
});
|
|
5671
|
+
|
|
5672
|
+
// packages/markdownlint/src/index.ts
|
|
5673
|
+
var src_exports = {};
|
|
5674
|
+
__export(src_exports, {
|
|
5675
|
+
default: () => src_default,
|
|
5676
|
+
init: () => init
|
|
5677
|
+
});
|
|
5678
|
+
module.exports = __toCommonJS(src_exports);
|
|
5679
|
+
var import_lodash = __toESM(require_lodash());
|
|
5668
5680
|
|
|
5669
5681
|
// packages/markdownlint/src/rules/index.ts
|
|
5670
|
-
var
|
|
5682
|
+
var SS01 = __toESM(require_no_default_alt_text());
|
|
5683
|
+
var SS03 = __toESM(require_no_empty_alt_text());
|
|
5684
|
+
var SS02 = __toESM(require_no_generic_link_text());
|
|
5685
|
+
var rules = [SS01, SS02, SS03];
|
|
5671
5686
|
|
|
5672
5687
|
// packages/markdownlint/src/style/accessibility.json
|
|
5673
5688
|
var accessibility_default = {
|
|
@@ -5700,9 +5715,9 @@ var base_default = {
|
|
|
5700
5715
|
};
|
|
5701
5716
|
|
|
5702
5717
|
// packages/markdownlint/src/index.ts
|
|
5703
|
-
var offByDefault = [
|
|
5718
|
+
var offByDefault = [];
|
|
5704
5719
|
for (const rule of rules) {
|
|
5705
|
-
const ruleName = rule
|
|
5720
|
+
const ruleName = rule?.names[1];
|
|
5706
5721
|
if (ruleName) {
|
|
5707
5722
|
base_default[ruleName] = offByDefault.includes(ruleName) ? false : true;
|
|
5708
5723
|
}
|