@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.
Files changed (3) hide show
  1. package/CHANGELOG.md +7 -0
  2. package/index.js +160 -145
  3. package/package.json +1 -1
package/CHANGELOG.md CHANGED
@@ -1,3 +1,10 @@
1
+ ## 0.5.1 (2024-06-05)
2
+
3
+
4
+ ### 🩹 Fixes
5
+
6
+ - **markdownlint:** Resolve issue with bad rules export ([7e6e5375](https://github.com/storm-software/storm-ops/commit/7e6e5375))
7
+
1
8
  ## 0.5.0 (2024-06-05)
2
9
 
3
10
  ### πŸš€ Features
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 defaultScreenshotRegex = `(?:screen|clean) ?(?:shot|cast) \\d{4}-\\d{2}-\\d{2}[^'"\\]]*`;
5523
- var imageRegex = "image";
5524
- var combinedRegex = `(${[defaultScreenshotRegex, imageRegex].join("|")})`;
5525
- var markdownAltRegex = new RegExp(`!\\[${combinedRegex}\\]\\(.*\\)`, "gid");
5526
- var htmlAltRegex = new RegExp(`alt=["']${combinedRegex}["']`, "gid");
5527
- var no_default_alt_text_default = {
5528
- names: ["SS001", "no-default-alt-text"],
5529
- description: "Images should have meaningful alternative text (alt text)",
5530
- information: new URL(
5531
- "https://github.com/github/markdownlint-github/blob/main/docs/rules/GH001-no-default-alt-text.md"
5532
- ),
5533
- tags: ["accessibility", "images"],
5534
- function: function SS001(params, onError) {
5535
- const htmlTagsWithImages = params.parsers.markdownit.tokens.filter(
5536
- (token) => {
5537
- return token.type === "html_block" && token.content.includes("<img") || token.type === "inline" && token.content.includes("<img") && token.children.some((child) => child.type === "html_inline");
5538
- }
5539
- );
5540
- const inlineImages = params.parsers.markdownit.tokens.filter(
5541
- (token) => token.type === "inline" && token.children.some((child) => child.type === "image")
5542
- );
5543
- for (const token of [...htmlTagsWithImages, ...inlineImages]) {
5544
- const lineRange = token.map;
5545
- const lineNumber = token.lineNumber;
5546
- const lines = params.lines.slice(lineRange[0], lineRange[1]);
5547
- for (let i = 0; i < lines.length; i++) {
5548
- const line = lines[i];
5549
- let matches;
5550
- if (token.type === "inline") {
5551
- if (token.children.some((child) => child.type === "html_inline")) {
5552
- matches = line.matchAll(htmlAltRegex);
5553
- } else {
5554
- matches = line.matchAll(markdownAltRegex);
5555
- }
5556
- } else {
5557
- matches = line.matchAll(htmlAltRegex);
5558
- }
5559
- for (const match of matches) {
5560
- const altText = match[1];
5561
- const [startIndex] = match.indices[1];
5562
- onError({
5563
- lineNumber: lineNumber + i,
5564
- range: [startIndex + 1, altText.length],
5565
- detail: `Flagged alt: ${altText}`
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-generic-link-text.ts
5574
- function stripAndDowncaseText(text) {
5575
- return text.toLowerCase().replace(/[.,/#!$%^&*;:{}=\-_`~()]/g, "").replace(/\s+/g, " ").trim();
5576
- }
5577
- var bannedLinkText = [
5578
- "read more",
5579
- "learn more",
5580
- "more",
5581
- "here",
5582
- "click here",
5583
- "link"
5584
- ];
5585
- var no_generic_link_text_default = {
5586
- names: ["SS002", "no-generic-link-text"],
5587
- description: "Avoid using generic link text like `Learn more` or `Click here`",
5588
- information: new URL(
5589
- "https://github.com/github/markdownlint-github/blob/main/docs/rules/GH002-no-generic-link-text.md"
5590
- ),
5591
- tags: ["accessibility", "links"],
5592
- function: function SS002(params, onError) {
5593
- let bannedLinkTexts = bannedLinkText.concat(
5594
- params.config.additional_banned_texts || []
5595
- );
5596
- const exceptions = params.config.exceptions || [];
5597
- if (exceptions.length > 0) {
5598
- bannedLinkTexts = bannedLinkTexts.filter(
5599
- (text) => !exceptions.includes(text)
5600
- );
5601
- }
5602
- const inlineTokens = params.tokens.filter((t) => t.type === "inline");
5603
- for (const token of inlineTokens) {
5604
- const { children } = token;
5605
- let inLink = false;
5606
- let linkText = "";
5607
- for (const child of children) {
5608
- const { content, type } = child;
5609
- if (type === "link_open") {
5610
- inLink = true;
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-empty-alt-text.ts
5629
- var no_empty_alt_text_default = {
5630
- names: ["SS003", "no-empty-alt-text"],
5631
- description: "Please provide an alternative text for the image.",
5632
- information: new URL(
5633
- "https://github.com/github/markdownlint-github/blob/main/docs/rules/GH003-no-empty-alt-text.md"
5634
- ),
5635
- tags: ["accessibility", "images"],
5636
- function: function SS003(params, onError) {
5637
- const htmlTagsWithImages = params.parsers.markdownit.tokens.filter(
5638
- (token) => {
5639
- return token.type === "html_block" && token.content.includes("<img") || token.type === "inline" && token.content.includes("<img") && token.children.some((child) => child.type === "html_inline");
5640
- }
5641
- );
5642
- const ImageRegex = new RegExp(/<img(.*?)>/, "gid");
5643
- const htmlEmptyAltRegex = new RegExp(/alt=['"]['"]/, "gid");
5644
- for (const token of htmlTagsWithImages) {
5645
- const lineRange = token.map;
5646
- const lineNumber = token.lineNumber;
5647
- const lines = params.lines.slice(lineRange[0], lineRange[1]);
5648
- for (const [i, line] of lines.entries()) {
5649
- const imageTags = line.matchAll(ImageRegex);
5650
- for (const imageTag of imageTags) {
5651
- const imageTagIndex = imageTag.indices[0][0];
5652
- const emptyAltMatches = [
5653
- ...imageTag[0].matchAll(htmlEmptyAltRegex)
5654
- ][0];
5655
- if (emptyAltMatches) {
5656
- const matchingContent = emptyAltMatches[0];
5657
- const startIndex = emptyAltMatches.indices[0][0];
5658
- onError({
5659
- lineNumber: lineNumber + i,
5660
- range: [imageTagIndex + startIndex + 1, matchingContent.length]
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 rules = [no_default_alt_text_default, no_generic_link_text_default, no_empty_alt_text_default];
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 = ["no-empty-alt-text"];
5718
+ var offByDefault = [];
5704
5719
  for (const rule of rules) {
5705
- const ruleName = rule.names[1];
5720
+ const ruleName = rule?.names[1];
5706
5721
  if (ruleName) {
5707
5722
  base_default[ruleName] = offByDefault.includes(ruleName) ? false : true;
5708
5723
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@storm-software/markdownlint",
3
- "version": "0.5.0",
3
+ "version": "0.5.1",
4
4
  "type": "commonjs",
5
5
  "description": "⚑An opinionated collection of markdownlint rules used by Storm Software.",
6
6
  "repository": {