@diplodoc/yfmlint 1.3.0 → 1.3.2

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/build/index.js CHANGED
@@ -21585,6 +21585,11 @@ var yfm002 = {
21585
21585
  };
21586
21586
 
21587
21587
  // src/rules/yfm003.ts
21588
+ var REASON_DESCRIPTION = {
21589
+ "file-not-found": "File does not exist in the project",
21590
+ "missing-in-toc": "File exists but is not declared in toc",
21591
+ "missing-in-toc-and-file-not-found": "File does not exist and is not declared in toc"
21592
+ };
21588
21593
  var yfm003 = {
21589
21594
  names: ["YFM003", "unreachable-link"],
21590
21595
  description: "Link is unreachable",
@@ -21600,13 +21605,20 @@ var yfm003 = {
21600
21605
  }).forEach((inline) => {
21601
21606
  var _a;
21602
21607
  (_a = inline.children) == null ? void 0 : _a.filter((child) => {
21603
- return child.type === "link_open";
21608
+ return child && child.type === "link_open";
21604
21609
  }).forEach((link) => {
21605
- if (link.attrGet("YFM003")) {
21606
- const linkHrefError = `[Unreachable link: "${link.attrGet("href")}"]`;
21610
+ const linkToken = link;
21611
+ const reason = linkToken.attrGet("YFM003");
21612
+ if (reason) {
21613
+ const reasonDescription = typeof reason === "string" && REASON_DESCRIPTION[reason] ? `Reason: ${REASON_DESCRIPTION[reason]}` : "";
21614
+ const context = [
21615
+ `Unreachable link: "${linkToken.attrGet("href")}"`,
21616
+ reasonDescription,
21617
+ `Line: ${link.line || inline.line}`
21618
+ ].filter(Boolean).join("; ");
21607
21619
  onError({
21608
- lineNumber: link.lineNumber,
21609
- context: linkHrefError + link.line
21620
+ lineNumber: link.lineNumber || inline.lineNumber,
21621
+ context
21610
21622
  });
21611
21623
  }
21612
21624
  });