8000
We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 81d52d7 commit dfe5d11Copy full SHA for dfe5d11
tools/lint-md.js
@@ -12,6 +12,7 @@ var tty = require('tty');
12
var fs$1 = require('fs');
13
var events = require('events');
14
var assert = require('assert');
15
+var require$$0$4 = require('url');
16
17
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
18
@@ -24,6 +25,7 @@ var tty__default = /*#__PURE__*/_interopDefaultLegacy(tty);
24
25
var fs__default = /*#__PURE__*/_interopDefaultLegacy(fs$1);
26
var events__default = /*#__PURE__*/_interopDefaultLegacy(events);
27
var assert__default = /*#__PURE__*/_interopDefaultLegacy(assert);
28
+var require$$0__default$1 = /*#__PURE__*/_interopDefaultLegacy(require$$0$4);
29
30
var vfileStatistics = statistics;
31
@@ -45048,6 +45050,51 @@ function noTrailingSpaces(ast, file) {
45048
45050
}
45049
45051
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
45087
+ `Unordered reference ("${node.label}" should be before "${previousDefinitionLabel}")`,
45088
45089
45090
45091
+ previousDefinitionLabel = node.label;
45092
45093
45094
45095
45096
+var remarkLintNodejsLinks = unifiedLintRule("remark-lint:nodejs-links", validateLinks);
45097
45098
function isNothing$1(subject) {
45099
return (typeof subject === 'undefined') || (subject === null);
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
);
@@ -50532,6 +50579,7 @@ var plugins$2 = [
50532
50579
remarkLintNoTableIndentation,
50533
50580
remarkLintNoTabs,
50534
50581
remarkLintNoTrailingSpaces,
50582
+ remarkLintNodejsLinks,
50535
50583
remarkLintNodejsYamlComments,
50536
50584
[
50537
50585
remarkLintProhibitedStrings,
tools/node-lint-md-cli-rollup/package-lock.json