remark-validate-links
Advanced tools
Comparing version 10.0.2 to 10.0.3
@@ -32,4 +32,5 @@ 'use strict' | ||
function onaccess(err) { | ||
var noEntry = err && (err.code === 'ENOENT' || err.code === 'ENOTDIR') | ||
function onaccess(error) { | ||
var noEntry = | ||
error && (error.code === 'ENOENT' || error.code === 'ENOTDIR') | ||
@@ -36,0 +37,0 @@ landmarks[filePath] = {'': !noEntry} |
@@ -39,8 +39,8 @@ 'use strict' | ||
function onremote(err, stdout) { | ||
function onremote(error, stdout) { | ||
var remote | ||
if (err) { | ||
if (error) { | ||
expected = Infinity | ||
return next(err) | ||
return next(error) | ||
} | ||
@@ -62,8 +62,8 @@ | ||
function oncdup(err, stdout) { | ||
function oncdup(error, stdout) { | ||
var out | ||
if (err) { | ||
if (error) { | ||
expected = Infinity | ||
return next(err) | ||
return next(error) | ||
} | ||
@@ -70,0 +70,0 @@ |
@@ -63,3 +63,3 @@ 'use strict' | ||
var id = props.name || props.id || data.id | ||
var info = node.url ? urlToPath(node.url, config) : null | ||
var info = node.url ? urlToPath(node.url, config, node.type) : null | ||
var fp | ||
@@ -186,3 +186,3 @@ var hash | ||
function urlToPath(value, config) { | ||
function urlToPath(value, config, type) { | ||
var url | ||
@@ -192,3 +192,3 @@ var questionMarkIndex | ||
// Absolute paths: `/wooorm/test/blob/master/directory/example.md`. | ||
// Absolute paths: `/wooorm/test/blob/main/directory/example.md`. | ||
if (value.charAt(0) === slash) { | ||
@@ -207,3 +207,3 @@ if (!config.hostname) { | ||
// URLs: `https://github.com/wooorm/test/blob/master/directory/example.md`. | ||
// URLs: `https://github.com/wooorm/test/blob/main/directory/example.md`. | ||
if (url) { | ||
@@ -229,3 +229,6 @@ // Exit if we don’t have hosted Git info or this is not a URL to the repo. | ||
return normalize(path.resolve(config.root, value + url.hash), config) | ||
return normalize( | ||
path.resolve(config.root, value + (type === 'image' ? '' : url.hash)), | ||
config | ||
) | ||
} | ||
@@ -245,4 +248,10 @@ | ||
(numberSignIndex === -1 ? '' : value.slice(numberSignIndex)) | ||
numberSignIndex = value.indexOf(numberSign) | ||
} | ||
// Ignore "headings" in image links: `image.png#metadata` | ||
if (numberSignIndex !== -1 && type === 'image') { | ||
value = value.slice(0, numberSignIndex) | ||
} | ||
// Local: `#heading`. | ||
@@ -249,0 +258,0 @@ if (value.charAt(0) === numberSign) { |
@@ -26,5 +26,5 @@ 'use strict' | ||
function done(err) { | ||
if (err) { | ||
next(err) | ||
function done(error) { | ||
if (error) { | ||
next(error) | ||
} else if (fileSet) { | ||
@@ -46,5 +46,5 @@ next() | ||
// Check all references and landmarks. | ||
check.run({files: files}, function (err) { | ||
next(err) | ||
check.run({files: files}, function (error) { | ||
next(error) | ||
}) | ||
} |
{ | ||
"name": "remark-validate-links", | ||
"version": "10.0.2", | ||
"version": "10.0.3", | ||
"description": "remark plugin to validate links to headings and files", | ||
@@ -56,5 +56,5 @@ "license": "MIT", | ||
"prettier": "^2.0.0", | ||
"remark": "^12.0.0", | ||
"remark-cli": "^8.0.0", | ||
"remark-preset-wooorm": "^7.0.0", | ||
"remark": "^13.0.0", | ||
"remark-cli": "^9.0.0", | ||
"remark-preset-wooorm": "^8.0.0", | ||
"rimraf": "^3.0.0", | ||
@@ -64,6 +64,6 @@ "strip-ansi": "^6.0.0", | ||
"vfile-sort": "^2.0.0", | ||
"xo": "^0.32.0" | ||
"xo": "^0.38.0" | ||
}, | ||
"scripts": { | ||
"format": "remark *.md -qfo && prettier --write \"**/*.js\" && xo --fix", | ||
"format": "remark . -qfo --ignore-pattern test/ && prettier . -w --loglevel warn && xo --fix", | ||
"test-api": "node test", | ||
@@ -91,6 +91,9 @@ "test-coverage": "nyc --reporter lcov tape test/index.js", | ||
"rules": { | ||
"complexity": "off", | ||
"guard-for-in": "off", | ||
"unicorn/no-array-callback-reference": "off", | ||
"unicorn/no-array-for-each": "off", | ||
"unicorn/prefer-number-properties": "off", | ||
"unicorn/prefer-optional-catch-binding": "off", | ||
"unicorn/no-fn-reference-in-iterator": "off", | ||
"unicorn/prefer-includes": "off", | ||
"guard-for-in": "off" | ||
"unicorn/prefer-includes": "off" | ||
} | ||
@@ -97,0 +100,0 @@ }, |
@@ -13,11 +13,9 @@ # remark-validate-links | ||
existing local files and headings. | ||
It does not check external URLs (see [`remark-lint-no-dead-urls`][no-dead-urls] | ||
for that). | ||
For example, this document does not have a heading named `Hello`. | ||
So if we link to that (`[welcome](#hello)`), this plugin will warn about it. | ||
So if we’d link to it (`[welcome](#hello)`), we’d get a warning. | ||
In addition, when there’s a link to a heading in another document | ||
(`examples/foo.md#hello`), if this file exists but the heading does not, or if | ||
the file does not exist, this plugin will also warn. | ||
(`examples/foo.md#hello`), if that file exists but the heading does not, or if | ||
that file does not exist, we’d also get a warning. | ||
@@ -27,4 +25,14 @@ Linking to other files, such as `license` or `index.js` (when they exist) is | ||
## Table of Contents | ||
This plugin does not check external URLs (see | ||
[`remark-lint-no-dead-urls`][no-dead-urls]) or undefined references | ||
(see [`remark-lint-no-undefined-references`][no-undef-refs]). | ||
## Note! | ||
This plugin is ready for the new parser in remark | ||
([`remarkjs/remark#536`](https://github.com/remarkjs/remark/pull/536)). | ||
No change is needed: it works exactly the same now as it did before! | ||
## Contents | ||
* [Install](#install) | ||
@@ -68,3 +76,3 @@ * [Use](#use) | ||
But this does exist: [LICENSE](LICENSE). | ||
But this does exist: [license](license). | ||
@@ -100,13 +108,18 @@ So does this: [README](readme.md#installation). | ||
Links are checked: | ||
This [exists](#alpha). | ||
This [one does not](#does-not). | ||
References and definitions are [checked][alpha] [too][charlie]. | ||
# Bravo | ||
Headings in `readme.md` are [not checked](readme.md#bravo). | ||
But [missing files are reported](missing-example.js). | ||
Headings in `readme.md` are [checked](readme.md#nosuchheading). | ||
And [missing files are reported](missing-example.js). | ||
Definitions are also checked: | ||
[alpha]: #alpha | ||
[charlie]: #charlie | ||
References w/o definitions are not checked: [delta] | ||
``` | ||
@@ -124,3 +137,3 @@ | ||
.use(links) | ||
.process(vfile.readSync('example.md'), function(err, file) { | ||
.process(vfile.readSync('example.md'), function (err, file) { | ||
console.error(report(err || file)) | ||
@@ -134,5 +147,5 @@ }) | ||
example.md | ||
4:6-4:31 warning Link to unknown heading: `does-not` missing-heading remark-validate-links | ||
10:5-10:53 warning Link to unknown file: `missing-example.js` missing-file remark-validate-links | ||
13:1-13:20 warning Link to unknown heading: `charlie` missing-heading remark-validate-links | ||
6:6-6:31 warning Link to unknown heading: `does-not` missing-heading remark-validate-links | ||
11:5-11:53 warning Link to unknown file: `missing-example.js` missing-file remark-validate-links | ||
16:1-16:20 warning Link to unknown heading: `charlie` missing-heading remark-validate-links | ||
@@ -142,2 +155,5 @@ ⚠ 3 warnings | ||
(Note that `readme.md#nosuchheading` is not warned about, because the API | ||
does not check headings in other Markdown files). | ||
## Configuration | ||
@@ -147,4 +163,4 @@ | ||
local Git repositories. | ||
If one is detected that references a known Git host, some extra links can be | ||
checked. | ||
If one is detected that references a known Git host (GitHub, GitLab, | ||
or Bitbucket), some extra links can be checked. | ||
If one is detected that does not reference a known Git host, local links still | ||
@@ -257,5 +273,5 @@ work as expected. | ||
[build-badge]: https://img.shields.io/travis/remarkjs/remark-validate-links/master.svg | ||
[build-badge]: https://github.com/remarkjs/remark-validate-links/workflows/main/badge.svg | ||
[build]: https://travis-ci.org/remarkjs/remark-validate-links | ||
[build]: https://github.com/remarkjs/remark-validate-links/actions | ||
@@ -280,5 +296,5 @@ [coverage-badge]: https://img.shields.io/codecov/c/github/remarkjs/remark-validate-links.svg | ||
[chat-badge]: https://img.shields.io/badge/chat-spectrum-7b16ff.svg | ||
[chat-badge]: https://img.shields.io/badge/chat-discussions-success.svg | ||
[chat]: https://spectrum.chat/unified/remark | ||
[chat]: https://github.com/remarkjs/remark/discussions | ||
@@ -289,7 +305,7 @@ [npm]: https://docs.npmjs.com/cli/install | ||
[contributing]: https://github.com/remarkjs/.github/blob/master/contributing.md | ||
[contributing]: https://github.com/remarkjs/.github/blob/HEAD/contributing.md | ||
[support]: https://github.com/remarkjs/.github/blob/master/support.md | ||
[support]: https://github.com/remarkjs/.github/blob/HEAD/support.md | ||
[coc]: https://github.com/remarkjs/.github/blob/master/code-of-conduct.md | ||
[coc]: https://github.com/remarkjs/.github/blob/HEAD/code-of-conduct.md | ||
@@ -302,3 +318,3 @@ [license]: license | ||
[cli]: https://github.com/remarkjs/remark/tree/master/packages/remark-cli#readme | ||
[cli]: https://github.com/remarkjs/remark/tree/HEAD/packages/remark-cli#readme | ||
@@ -311,2 +327,4 @@ [remark-lint]: https://github.com/remarkjs/remark-lint | ||
[no-undef-refs]: https://github.com/remarkjs/remark-lint/tree/master/packages/remark-lint-no-undefined-references | ||
[package-repository]: https://docs.npmjs.com/files/package.json#repository | ||
@@ -313,0 +331,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
29760
598
322