| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -12,6 +12,7 @@ var tty = require('tty'); | |||
| 12 | 12 | var fs$1 = require('fs'); | |
| 13 | 13 | var events = require('events'); | |
| 14 | 14 | var assert = require('assert'); | |
| 15 | + var require$$0$4 = require('url'); | ||
| 15 | 16 | ||
| 16 | 17 | function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; } | |
| 17 | 18 | ||
@@ -24,6 +25,7 @@ var tty__default = /*#__PURE__*/_interopDefaultLegacy(tty); | |||
| 24 | 25 | var fs__default = /*#__PURE__*/_interopDefaultLegacy(fs$1); | |
| 25 | 26 | var events__default = /*#__PURE__*/_interopDefaultLegacy(events); | |
| 26 | 27 | var assert__default = /*#__PURE__*/_interopDefaultLegacy(assert); | |
| 28 | + var require$$0__default$1 = /*#__PURE__*/_interopDefaultLegacy(require$$0$4); | ||
| 27 | 29 | ||
| 28 | 30 | var vfileStatistics = statistics; | |
| 29 | 31 | ||
@@ -45048,6 +45050,51 @@ function noTrailingSpaces(ast, file) { | |||
| 45048 | 45050 | } | |
| 45049 | 45051 | } | |
| 45050 | 45052 | ||
| 45053 | + const { pathToFileURL } = require$$0__default$1['default']; | ||
| 45054 | + | ||
| 45055 | + | ||
| 45056 | + | ||
| 45057 | + function* getLinksRecursively(node) { | ||
| 45058 | + if (node.url) { | ||
| 45059 | + yield node; | ||
| 45060 | + } | ||
| 45061 | + for (const child of node.children || []) { | ||
| 45062 | + yield* getLinksRecursively(child); | ||
| 45063 | + } | ||
| 45064 | + } | ||
| 45065 | + | ||
| 45066 | + function validateLinks(tree, vfile) { | ||
| 45067 | + const currentFileURL = pathToFileURL(path__default['default'].join(vfile.cwd, vfile.path)); | ||
| 45068 | + let previousDefinitionLabel; | ||
| 45069 | + for (const node of getLinksRecursively(tree)) { | ||
| 45070 | + if (node.url[0] !== "#") { | ||
| 45071 | + const targetURL = new URL(node.url, currentFileURL); | ||
| 45072 | + if (targetURL.protocol === "file:" && !fs__default['default'].existsSync(targetURL)) { | ||
| 45073 | + vfile.message("Broken link", node); | ||
| 45074 | + } else if (targetURL.pathname === currentFileURL.pathname) { | ||
| 45075 | + const expected = node.url.includes("#") | ||
| 45076 | + ? node.url.slice(node.url.indexOf("#")) | ||
| 45077 | + : "#"; | ||
| 45078 | + vfile.message( | ||
| 45079 | + `Self-reference must start with hash (expected "${expected}", got "${node.url}")`, | ||
| 45080 | + node | ||
| 45081 | + ); | ||
| 45082 | + } | ||
| 45083 | + } | ||
| 45084 | + if (node.type === "definition") { | ||
| 45085 | + if (previousDefinitionLabel && previousDefinitionLabel > node.label) { | ||
| 45086 | + vfile.message( | ||
| 45087 | + `Unordered reference ("${node.label}" should be before "${previousDefinitionLabel}")`, | ||
| 45088 | + node | ||
| 45089 | + ); | ||
| 45090 | + } | ||
| 45091 | + previousDefinitionLabel = node.label; | ||
| 45092 | + } | ||
| 45093 | + } | ||
| 45094 | + } | ||
| 45095 | + | ||
| 45096 | + var remarkLintNodejsLinks = unifiedLintRule("remark-lint:nodejs-links", validateLinks); | ||
| 45097 | + | ||
| 45051 | 45098 | function isNothing$1(subject) { | |
| 45052 | 45099 | return (typeof subject === 'undefined') || (subject === null); | |
| 45053 | 45100 | } | |
@@ -49632,7 +49679,7 @@ function validateMeta(node, file, meta) { | |||
| 49632 | 49679 | ||
| 49633 | 49680 | case kWrongKeyOrder: | |
| 49634 | 49681 | file.message( | |
| 49635 | - "YAML dictionary keys should be respect this order: " + | ||
| 49682 | + "YAML dictionary keys should be in this order: " + | ||
| 49636 | 49683 | allowedKeys.join(", "), | |
| 49637 | 49684 | node | |
| 49638 | 49685 | ); | |
@@ -50527,6 +50574,7 @@ var plugins$2 = [ | |||
| 50527 | 50574 | remarkLintNoTableIndentation, | |
| 50528 | 50575 | remarkLintNoTabs, | |
| 50529 | 50576 | remarkLintNoTrailingSpaces, | |
| 50577 | + remarkLintNodejsLinks, | ||
| 50530 | 50578 | remarkLintNodejsYamlComments, | |
| 50531 | 50579 | [ | |
| 50532 | 50580 | remarkLintProhibitedStrings, | |
| Back | FazBrowse Home | New Git URL |
0 commit comments