Skip to content

Commit dfe5d11

Browse files
Trotttargos
authored andcommitted
tools: update remark-preset-lint-node to 2.4.1
PR-URL: #39201 Reviewed-By: Michaël Zasso <[email protected]> Reviewed-By: Antoine du Hamel <[email protected]>
1 parent 81d52d7 commit dfe5d11

File tree

2 files changed

+61
-9
lines changed

2 files changed

+61
-9
lines changed

Diff for: tools/lint-md.js

+49-1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ var tty = require('tty');
1212
var fs$1 = require('fs');
1313
var events = require('events');
1414
var assert = require('assert');
15+
var require$$0$4 = require('url');
1516

1617
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
1718

@@ -24,6 +25,7 @@ var tty__default = /*#__PURE__*/_interopDefaultLegacy(tty);
2425
var fs__default = /*#__PURE__*/_interopDefaultLegacy(fs$1);
2526
var events__default = /*#__PURE__*/_interopDefaultLegacy(events);
2627
var assert__default = /*#__PURE__*/_interopDefaultLegacy(assert);
28+
var require$$0__default$1 = /*#__PURE__*/_interopDefaultLegacy(require$$0$4);
2729

2830
var vfileStatistics = statistics;
2931

@@ -45048,6 +45050,51 @@ function noTrailingSpaces(ast, file) {
4504845050
}
4504945051
}
4505045052

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+
4505145098
function isNothing$1(subject) {
4505245099
return (typeof subject === 'undefined') || (subject === null);
4505345100
}
@@ -49632,7 +49679,7 @@ function validateMeta(node, file, meta) {
4963249679

4963349680
case kWrongKeyOrder:
4963449681
file.message(
49635-
"YAML dictionary keys should be respect this order: " +
49682+
"YAML dictionary keys should be in this order: " +
4963649683
allowedKeys.join(", "),
4963749684
node
4963849685
);
@@ -50532,6 +50579,7 @@ var plugins$2 = [
5053250579
remarkLintNoTableIndentation,
5053350580
remarkLintNoTabs,
5053450581
remarkLintNoTrailingSpaces,
50582+
remarkLintNodejsLinks,
5053550583
remarkLintNodejsYamlComments,
5053650584
[
5053750585
remarkLintProhibitedStrings,

Diff for: tools/node-lint-md-cli-rollup/package-lock.json

+12-8
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)