@storm-software/markdownlint 0.4.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 (4) hide show
  1. package/CHANGELOG.md +35 -21
  2. package/README.md +1 -1
  3. package/index.js +168 -153
  4. package/package.json +1 -1
package/CHANGELOG.md CHANGED
@@ -1,62 +1,75 @@
1
- ## 0.4.0 (2024-06-05)
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))
2
7
 
8
+ ## 0.5.0 (2024-06-05)
3
9
 
4
10
  ### 🚀 Features
5
11
 
6
- - **eslint-plugin:** Added the `eslint` and `prittier` base packages ([b2d63d0f](https://github.com/storm-software/storm-ops/commit/b2d63d0f))
12
+ - **eslint-plugin:** Added the `apply` helper function
13
+ ([ab919d5e](https://github.com/storm-software/storm-ops/commit/ab919d5e))
7
14
 
8
- - **workspace-tools:** Update `preset` generator with Storm `eslint-plugin` and `prettier` config ([24ae7683](https://github.com/storm-software/storm-ops/commit/24ae7683))
15
+ ## 0.4.0 (2024-06-05)
16
+
17
+ ### 🚀 Features
9
18
 
19
+ - **eslint-plugin:** Added the `eslint` and `prittier` base packages
20
+ ([b2d63d0f](https://github.com/storm-software/storm-ops/commit/b2d63d0f))
21
+
22
+ - **workspace-tools:** Update `preset` generator with Storm `eslint-plugin` and
23
+ `prettier` config
24
+ ([24ae7683](https://github.com/storm-software/storm-ops/commit/24ae7683))
10
25
 
11
26
  ### 🩹 Fixes
12
27
 
13
- - **eslint:** Resolve issue with missing dependencies ([b0f43454](https://github.com/storm-software/storm-ops/commit/b0f43454))
28
+ - **eslint:** Resolve issue with missing dependencies
29
+ ([b0f43454](https://github.com/storm-software/storm-ops/commit/b0f43454))
14
30
 
15
31
  ## 0.3.0 (2024-06-03)
16
32
 
17
-
18
33
  ### 🚀 Features
19
34
 
20
- - **storm-ops:** Upgrade Nx packages and resolve linting issues ([685c2bb9](https://github.com/storm-software/storm-ops/commit/685c2bb9))
21
-
35
+ - **storm-ops:** Upgrade Nx packages and resolve linting issues
36
+ ([685c2bb9](https://github.com/storm-software/storm-ops/commit/685c2bb9))
22
37
 
23
38
  ### 🩹 Fixes
24
39
 
25
- - **git-tools:** Resolved issue with import in markdown formatter ([5e3963de](https://github.com/storm-software/storm-ops/commit/5e3963de))
40
+ - **git-tools:** Resolved issue with import in markdown formatter
41
+ ([5e3963de](https://github.com/storm-software/storm-ops/commit/5e3963de))
26
42
 
27
43
  ## 0.2.0 (2024-05-29)
28
44
 
29
-
30
45
  ### 🚀 Features
31
46
 
32
- - **cloudflare-tools:** Update worker generator to add hono depenendency ([946a9e59](https://github.com/storm-software/storm-ops/commit/946a9e59))
33
-
47
+ - **cloudflare-tools:** Update worker generator to add hono depenendency
48
+ ([946a9e59](https://github.com/storm-software/storm-ops/commit/946a9e59))
34
49
 
35
- ### ❤️ Thank You
50
+ ### ❤️ Thank You
36
51
 
37
52
  - Patrick Sullivan
38
53
 
39
54
  ## 0.1.2 (2024-05-27)
40
55
 
41
-
42
56
  ### 🩹 Fixes
43
57
 
44
- - **deps:** pin dependencies ([604f8bbb](https://github.com/storm-software/storm-ops/commit/604f8bbb))
58
+ - **deps:** pin dependencies
59
+ ([604f8bbb](https://github.com/storm-software/storm-ops/commit/604f8bbb))
45
60
 
46
-
47
- ### ❤️ Thank You
61
+ ### ❤️ Thank You
48
62
 
49
63
  - Patrick Sullivan
50
64
 
51
65
  ## 0.1.1 (2024-05-06)
52
66
 
53
-
54
67
  ### 🩹 Fixes
55
68
 
56
- - **markdownlint:** Resolved issue with bad config in lint file ([95b3aba7](https://github.com/storm-software/storm-ops/commit/95b3aba7))
69
+ - **markdownlint:** Resolved issue with bad config in lint file
70
+ ([95b3aba7](https://github.com/storm-software/storm-ops/commit/95b3aba7))
57
71
 
58
-
59
- ### ❤️ Thank You
72
+ ### ❤️ Thank You
60
73
 
61
74
  - Patrick Sullivan
62
75
 
@@ -64,7 +77,8 @@
64
77
 
65
78
  ### 🚀 Features
66
79
 
67
- - **markdownlint:** Added the `markdownlint` package for shared configurations ([abd6fa38](https://github.com/storm-software/storm-ops/commit/abd6fa38))
80
+ - **markdownlint:** Added the `markdownlint` package for shared configurations
81
+ ([abd6fa38](https://github.com/storm-software/storm-ops/commit/abd6fa38))
68
82
 
69
83
  ### ❤️ Thank You
70
84
 
package/README.md CHANGED
@@ -21,7 +21,7 @@ This package is part of the <b>⚡Storm-Ops</b> monorepo. The Storm-Ops packages
21
21
 
22
22
  <h3 align="center">💻 Visit <a href="https://stormsoftware.com" target="_blank">stormsoftware.com</a> to stay up to date with this developer</h3><br />
23
23
 
24
- [![Version](https://img.shields.io/badge/version-0.3.0-1fb2a6.svg?style=for-the-badge&color=1fb2a6)](https://prettier.io/)&nbsp;
24
+ [![Version](https://img.shields.io/badge/version-0.5.0-1fb2a6.svg?style=for-the-badge&color=1fb2a6)](https://prettier.io/)&nbsp;
25
25
  [![Nx](https://img.shields.io/badge/Nx-17.0.2-lightgrey?style=for-the-badge&logo=nx&logoWidth=20&&color=1fb2a6)](http://nx.dev/)&nbsp;[![NextJs](https://img.shields.io/badge/Next.js-14.0.2-lightgrey?style=for-the-badge&logo=nextdotjs&logoWidth=20&color=1fb2a6)](https://nextjs.org/)&nbsp;[![Commitizen friendly](https://img.shields.io/badge/commitizen-friendly-brightgreen.svg?style=for-the-badge&logo=commitlint&color=1fb2a6)](http://commitizen.github.io/cz-cli/)&nbsp;![Semantic-Release](https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg?style=for-the-badge&color=1fb2a6)&nbsp;[![documented with docusaurus](https://img.shields.io/badge/documented_with-docusaurus-success.svg?style=for-the-badge&logo=readthedocs&color=1fb2a6)](https://docusaurus.io/)&nbsp;![GitHub Workflow Status (with event)](https://img.shields.io/github/actions/workflow/status/storm-software/storm-ops/cr.yml?style=for-the-badge&logo=github-actions&color=1fb2a6)
26
26
 
27
27
  > [!IMPORTANT]
package/index.js CHANGED
@@ -5509,6 +5509,166 @@ var require_lodash = __commonJS({
5509
5509
  }
5510
5510
  });
5511
5511
 
5512
+ // packages/markdownlint/src/rules/no-default-alt-text.ts
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
+ }
5562
+ }
5563
+ }
5564
+ };
5565
+ }
5566
+ });
5567
+
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
+ }
5606
+ }
5607
+ }
5608
+ }
5609
+ };
5610
+ }
5611
+ });
5612
+
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
+ }
5665
+ }
5666
+ }
5667
+ }
5668
+ };
5669
+ }
5670
+ });
5671
+
5512
5672
  // packages/markdownlint/src/index.ts
5513
5673
  var src_exports = {};
5514
5674
  __export(src_exports, {
@@ -5518,6 +5678,12 @@ __export(src_exports, {
5518
5678
  module.exports = __toCommonJS(src_exports);
5519
5679
  var import_lodash = __toESM(require_lodash());
5520
5680
 
5681
+ // packages/markdownlint/src/rules/index.ts
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];
5686
+
5521
5687
  // packages/markdownlint/src/style/accessibility.json
5522
5688
  var accessibility_default = {
5523
5689
  "no-alt-text": true,
@@ -5548,161 +5714,10 @@ var base_default = {
5548
5714
  "first-line-heading": false
5549
5715
  };
5550
5716
 
5551
- // packages/markdownlint/src/rules/no-default-alt-text.ts
5552
- var defaultScreenshotRegex = `(?:screen|clean) ?(?:shot|cast) \\d{4}-\\d{2}-\\d{2}[^'"\\]]*`;
5553
- var imageRegex = "image";
5554
- var combinedRegex = `(${[defaultScreenshotRegex, imageRegex].join("|")})`;
5555
- var markdownAltRegex = new RegExp(`!\\[${combinedRegex}\\]\\(.*\\)`, "gid");
5556
- var htmlAltRegex = new RegExp(`alt=["']${combinedRegex}["']`, "gid");
5557
- var no_default_alt_text_default = {
5558
- names: ["SS001", "no-default-alt-text"],
5559
- description: "Images should have meaningful alternative text (alt text)",
5560
- information: new URL(
5561
- "https://github.com/github/markdownlint-github/blob/main/docs/rules/GH001-no-default-alt-text.md"
5562
- ),
5563
- tags: ["accessibility", "images"],
5564
- function: function SS001(params, onError) {
5565
- const htmlTagsWithImages = params.parsers.markdownit.tokens.filter(
5566
- (token) => {
5567
- return token.type === "html_block" && token.content.includes("<img") || token.type === "inline" && token.content.includes("<img") && token.children.some((child) => child.type === "html_inline");
5568
- }
5569
- );
5570
- const inlineImages = params.parsers.markdownit.tokens.filter(
5571
- (token) => token.type === "inline" && token.children.some((child) => child.type === "image")
5572
- );
5573
- for (const token of [...htmlTagsWithImages, ...inlineImages]) {
5574
- const lineRange = token.map;
5575
- const lineNumber = token.lineNumber;
5576
- const lines = params.lines.slice(lineRange[0], lineRange[1]);
5577
- for (let i = 0; i < lines.length; i++) {
5578
- const line = lines[i];
5579
- let matches;
5580
- if (token.type === "inline") {
5581
- if (token.children.some((child) => child.type === "html_inline")) {
5582
- matches = line.matchAll(htmlAltRegex);
5583
- } else {
5584
- matches = line.matchAll(markdownAltRegex);
5585
- }
5586
- } else {
5587
- matches = line.matchAll(htmlAltRegex);
5588
- }
5589
- for (const match of matches) {
5590
- const altText = match[1];
5591
- const [startIndex] = match.indices[1];
5592
- onError({
5593
- lineNumber: lineNumber + i,
5594
- range: [startIndex + 1, altText.length],
5595
- detail: `Flagged alt: ${altText}`
5596
- });
5597
- }
5598
- }
5599
- }
5600
- }
5601
- };
5602
-
5603
- // packages/markdownlint/src/rules/no-generic-link-text.ts
5604
- function stripAndDowncaseText(text) {
5605
- return text.toLowerCase().replace(/[.,/#!$%^&*;:{}=\-_`~()]/g, "").replace(/\s+/g, " ").trim();
5606
- }
5607
- var bannedLinkText = [
5608
- "read more",
5609
- "learn more",
5610
- "more",
5611
- "here",
5612
- "click here",
5613
- "link"
5614
- ];
5615
- var no_generic_link_text_default = {
5616
- names: ["SS002", "no-generic-link-text"],
5617
- description: "Avoid using generic link text like `Learn more` or `Click here`",
5618
- information: new URL(
5619
- "https://github.com/github/markdownlint-github/blob/main/docs/rules/GH002-no-generic-link-text.md"
5620
- ),
5621
- tags: ["accessibility", "links"],
5622
- function: function SS002(params, onError) {
5623
- let bannedLinkTexts = bannedLinkText.concat(
5624
- params.config.additional_banned_texts || []
5625
- );
5626
- const exceptions = params.config.exceptions || [];
5627
- if (exceptions.length > 0) {
5628
- bannedLinkTexts = bannedLinkTexts.filter(
5629
- (text) => !exceptions.includes(text)
5630
- );
5631
- }
5632
- const inlineTokens = params.tokens.filter((t) => t.type === "inline");
5633
- for (const token of inlineTokens) {
5634
- const { children } = token;
5635
- let inLink = false;
5636
- let linkText = "";
5637
- for (const child of children) {
5638
- const { content, type } = child;
5639
- if (type === "link_open") {
5640
- inLink = true;
5641
- linkText = "";
5642
- } else if (type === "link_close") {
5643
- inLink = false;
5644
- if (bannedLinkTexts.includes(stripAndDowncaseText(linkText))) {
5645
- onError({
5646
- lineNumber: child.lineNumber,
5647
- detail: `For link: ${linkText}`
5648
- });
5649
- }
5650
- } else if (inLink) {
5651
- linkText += content;
5652
- }
5653
- }
5654
- }
5655
- }
5656
- };
5657
-
5658
- // packages/markdownlint/src/rules/no-empty-alt-text.ts
5659
- var no_empty_alt_text_default = {
5660
- names: ["SS003", "no-empty-alt-text"],
5661
- description: "Please provide an alternative text for the image.",
5662
- information: new URL(
5663
- "https://github.com/github/markdownlint-github/blob/main/docs/rules/GH003-no-empty-alt-text.md"
5664
- ),
5665
- tags: ["accessibility", "images"],
5666
- function: function SS003(params, onError) {
5667
- const htmlTagsWithImages = params.parsers.markdownit.tokens.filter(
5668
- (token) => {
5669
- return token.type === "html_block" && token.content.includes("<img") || token.type === "inline" && token.content.includes("<img") && token.children.some((child) => child.type === "html_inline");
5670
- }
5671
- );
5672
- const ImageRegex = new RegExp(/<img(.*?)>/, "gid");
5673
- const htmlEmptyAltRegex = new RegExp(/alt=['"]['"]/, "gid");
5674
- for (const token of htmlTagsWithImages) {
5675
- const lineRange = token.map;
5676
- const lineNumber = token.lineNumber;
5677
- const lines = params.lines.slice(lineRange[0], lineRange[1]);
5678
- for (const [i, line] of lines.entries()) {
5679
- const imageTags = line.matchAll(ImageRegex);
5680
- for (const imageTag of imageTags) {
5681
- const imageTagIndex = imageTag.indices[0][0];
5682
- const emptyAltMatches = [
5683
- ...imageTag[0].matchAll(htmlEmptyAltRegex)
5684
- ][0];
5685
- if (emptyAltMatches) {
5686
- const matchingContent = emptyAltMatches[0];
5687
- const startIndex = emptyAltMatches.indices[0][0];
5688
- onError({
5689
- lineNumber: lineNumber + i,
5690
- range: [imageTagIndex + startIndex + 1, matchingContent.length]
5691
- });
5692
- }
5693
- }
5694
- }
5695
- }
5696
- }
5697
- };
5698
-
5699
- // packages/markdownlint/src/rules/index.ts
5700
- var rules = [no_default_alt_text_default, no_generic_link_text_default, no_empty_alt_text_default];
5701
-
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.4.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": {