Gathering detailed insights and metrics for remark-validate-links
Gathering detailed insights and metrics for remark-validate-links
Gathering detailed insights and metrics for remark-validate-links
Gathering detailed insights and metrics for remark-validate-links
plugin to check that markdown links and images reference existing files and headings
npm install remark-validate-links
Typescript
Module System
Node Version
NPM Version
JavaScript (100%)
Total Downloads
0
Last Day
0
Last Week
0
Last Month
0
Last Year
0
MIT License
118 Stars
246 Commits
25 Forks
10 Watchers
1 Branches
23 Contributors
Updated on Jun 19, 2025
Latest Version
13.1.0
Package Id
remark-validate-links@13.1.0
Unpacked Size
49.81 kB
Size
15.24 kB
File Count
24
NPM Version
11.1.0
Node Version
23.1.0
Published on
Feb 21, 2025
Cumulative downloads
Total Downloads
Last Day
0%
NaN
Compared to previous day
Last Week
0%
NaN
Compared to previous week
Last Month
0%
NaN
Compared to previous month
Last Year
0%
NaN
Compared to previous year
remark plugin to check that markdown links and images point to existing local files and headings in a Git repo.
For example,
this document does not have a heading named Hello
.
So if we’d link to that heading ([welcome](#hello)
),
we’d get a warning.
Links to headings in other markdown documents (examples/foo.md#hello
) and
links to files (license
or index.js
) are also checked.
This is specifically for Git repos. Like this one. Not for say a website.
This package is a unified (remark) plugin to check local links in a Git repo.
This project is useful if you have a Git repo,
such as this one,
with docs in markdown and links to headings and other files,
and want to check whether they’re correct.
Compared to other links checkers,
this project can work offline
(making this plugin fast en prone to fewer false positives),
and is specifically made for local links in Git repos.
This plugin does not check external URLs
(see remark-lint-no-dead-urls
)
or undefined references (see
remark-lint-no-undefined-references
).
This package is ESM only. In Node.js (version 16+), install with npm:
1npm install remark-validate-links
In Deno with esm.sh
:
1import remarkValidateLinks from 'https://esm.sh/remark-validate-links@13'
In browsers with esm.sh
:
1<script type="module"> 2 import remarkValidateLinks from 'https://esm.sh/remark-validate-links@13?bundle' 3</script>
Say we have the following file example.md
in this project:
1# Alpha
2
3Links are checked:
4
5This [exists](#alpha).
6This [one does not](#apha).
7
8# Bravo
9
10Headings in `readme.md` are [checked](readme.md#no-such-heading).
11And [missing files are reported](missing-example.js).
12
13Definitions are also checked:
14
15[alpha]: #alpha
16[charlie]: #charlie
17
18References w/o definitions are not checked: [delta]
…and a module example.js
:
1import remarkValidateLinks from 'remark-validate-links' 2import {remark} from 'remark' 3import {read} from 'to-vfile' 4import {reporter} from 'vfile-reporter' 5 6const file = await remark() 7 .use(remarkValidateLinks) 8 .process(await read('example.md')) 9 10console.log(reporter(file))
…then running node example.js
yields:
1example.md
26:6-6:27 warning Cannot find heading for `#apha`; did you mean `alpha` missing-heading remark-validate-links:missing-heading
311:5-11:53 warning Cannot find file `missing-example.js` missing-file remark-validate-links:missing-file
416:1-16:20 warning Cannot find heading for `#charlie` missing-heading remark-validate-links:missing-heading
5
6⚠ 3 warnings
👉 Note:
readme.md#no-such-heading
is not warned about on the API, as the API does not check headings in other markdown files; the remark CLI is able to do that.
This package exports no identifiers.
The default export is remarkValidateLinks
.
It exports the TypeScript types
Options
and
UrlConfig
.
unified().use(remarkValidateLinks[, options])
Check that markdown links and images point to existing local files and headings in a Git repo.
⚠️ Important: the API in Node.js checks links to headings and files but does not check whether headings in other files exist; the API in browsers only checks links to headings in the same file; the CLI can check everything.
options
(Options
, optional)
— configurationTransform (Transformer
).
Options
Configuration (TypeScript type).
repository
(string
or false
, default: detected from Git remote)
— URL to hosted Git;
if you’re not in a Git repository,
you must pass false
;
if the repository resolves to something npm understands as a Git host such
as GitHub, GitLab, or Bitbucket,
then full URLs to that host
(say,
https://github.com/remarkjs/remark-validate-links/readme.md#install
)
are checkedroot
(string
, default: local Git folder)
— path to Git root folder;
if both root
and repository
are nullish,
the Git root is detected;
if root
is not given but repository
is,
file.cwd
is usedskipPathPatterns
(Array<RegExp | string>
, optional)
— list of patterns for paths that should be skipped;
each absolute local path + hash will be tested against each pattern and
will be ignored if new RegExp(pattern).test(value) === true
;
example value are then /Users/tilde/path/to/repo/readme.md#some-heading
.urlConfig
(UrlConfig
, default: detected from repo)
— config on how hosted Git works;
github.com
, gitlab.com
, or bitbucket.org
work automatically;
otherwise,
pass urlConfig
manuallyUrlConfig
Hosted Git info (TypeScript type).
headingPrefix
(string
, optional, example: '#'
, '#markdown-header-'
)
— prefix of headingshostname
(string
, optional, example: 'github.com'
,
'bitbucket.org'
)
— domain of URLslines
(boolean
, default: false
)
— whether lines in files can be linkedpath
(string
, optional, example:
'/remarkjs/remark-validate-links/blob/'
,
'/remarkjs/remark-validate-links/src/'
)
— path prefix before filestopAnchor
(string
, optional, example: #readme
)
— hash to top of readmeFor this repository (remarkjs/remark-validate-links
on GitHub) urlConfig
looks as follows:
1{ 2 // Prefix of headings: 3 headingPrefix: '#', 4 // Domain of URLs: 5 hostname: 'github.com', 6 // Whether lines in files can be linked: 7 lines: true, 8 // Path prefix before files: 9 prefix: '/remarkjs/remark-validate-links/blob/', 10 // Hash to top of markdown documents: 11 topAnchor: '#readme' 12}
If this project were hosted on Bitbucket, the config would be:
1{ 2 headingPrefix: '#markdown-header-', 3 hostname: 'bitbucket.org', 4 lines: false, 5 prefix: '/remarkjs/remark-validate-links/src/' 6}
It’s recommended to use remark-validate-links
on the CLI with
remark-cli
.
Install both with npm:
1npm install remark-cli remark-validate-links --save-dev
Let’s say we have a readme.md
(this current document) and an example.md
with the following text:
1# Hello 2 3Read more [whoops, this does not exist](#world). 4 5This doesn’t exist either [whoops!](readme.md#foo). 6 7But this does exist: [license](license). 8 9So does this: [readme](readme.md#install).
Now,
running ./node_modules/.bin/remark --use remark-validate-links .
yields:
1example.md 2 3:11-3:48 warning Link to unknown heading: `world` missing-heading remark-validate-links 3 5:27-5:51 warning Link to unknown heading in `readme.md`: `foo` missing-heading-in-file remark-validate-links 4 5readme.md: no issues found 6 7⚠ 2 warnings
You can use remark-validate-links
and remark-cli
in
an npm script to check and format markdown in your project.
Install both with npm:
1npm install remark-cli remark-validate-links --save-dev
Then,
add a format script and configuration to package.json
:
1{ 2 // … 3 "scripts": { 4 // … 5 "format": "remark . --quiet --frail --output", 6 // … 7 }, 8 "remarkConfig": { 9 "plugins": [ 10 "remark-validate-links" 11 ] 12 }, 13 // … 14}
💡 Tip: add other tools such as prettier or ESLint to check and format other files.
💡 Tip: run
./node_modules/.bin/remark --help
for help withremark-cli
.
Now you check and format markdown in your project with:
1npm run format
remark-validate-links
can detect anchors on nodes through several properties
on nodes:
node.data.hProperties.name
— used by
mdast-util-to-hast
to create a name
attribute,
which anchors can link tonode.data.hProperties.id
— used by
mdast-util-to-hast
to create an id
attribute,
which anchors can link tonode.data.id
— used potentially in the future by other tools to signal unique identifiers
on nodesProjects maintained by the unified collective are compatible with maintained versions of Node.js.
When we cut a new major release,
we drop support for unmaintained versions of Node.
This means we try to keep the current release line,
remark-validate-links@13
,
compatible with Node.js 16.
This plugin works with unified
version 6+,
remark
version 7+,
and remark-cli
version 8+.
remark-validate-links
,
in Node,
accesses the file system based on user content,
and this may be dangerous.
In Node git remote
and git rev-parse
also runs for processed files.
The tree is not modified, so there are no openings for cross-site scripting (XSS) attacks.
remark-lint
— markdown code style linterremark-lint-no-dead-urls
— check that external links are aliveSee contributing.md
in
remarkjs/.github
for ways to get started.
See support.md
for ways to get help.
This project has a code of conduct. By interacting with this repository, organization, or community you agree to abide by its terms.
No vulnerabilities found.
Reason
no dangerous workflow patterns detected
Reason
no binaries found in the repo
Reason
0 existing vulnerabilities detected
Reason
license file detected
Details
Reason
security policy file detected
Details
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
detected GitHub workflow tokens with excessive permissions
Details
Reason
Found 0/30 approved changesets -- score normalized to 0
Reason
no SAST tool detected
Details
Reason
dependency not pinned by hash detected -- score normalized to 0
Details
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
project is not fuzzed
Details
Reason
branch protection not enabled on development/release branches
Details
Score
Last Scanned on 2025-06-30
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More