remark-lint-relative-markdown-file-path-links
TypeScript icon, indicating that this package has built-in type declarations

0.1.1 • Public • Published

remark-lint-relative-markdown-file-path-links

remark-lint rule to warn when a link to another markdown document (md/mdx) is not a relative file path with extension.

If you are using Docusaurus, this can be used in combination with remark-validate-links to detect broken anchor links.

Contents

What is this?

This package is a unified (remark) plugin, specifically a remark-lint rule.

Lint rules check markdown code style.

Install

This package is ESM only.

In Node.js (16.0+), install with npm:

npm install --save-dev remark-lint-relative-markdown-file-path-links

Use

On the API:

import {read} from 'to-vfile'
import {reporter} from 'vfile-reporter'
import {remark} from 'remark'
import remarkLint from 'remark-lint'
import remarkLintRelativeMarkdownFilePathLinks from 'remark-lint-relative-markdown-file-path-links'

main()

async function main() {
  const file = await remark()
    .use(remarkLint)
    .use(remarkLintRelativeMarkdownFilePathLinks)
    .process(await read('example.md'))

  console.error(reporter(file))
}

On the CLI:

remark --use remark-lint --use remark-lint-relative-markdown-file-path-links example.md

On the CLI in a config file (here a package.json):

 …
 "remarkConfig": {
   "plugins": [
     …
     "remark-lint",
+    "remark-lint-relative-markdown-file-path-links",
     …
   ]
 }
 …

API

unified().use(remarkLintNoUnneededFullReferenceLink[, config])

This rule supports standard configuration that all remark lint rules accept (such as false to turn it off or [1, options] to configure it).

There are no options.

Examples

See test/test.md or run the test with npm test.

License

MIT © Riccardo Odone

Package Sidebar

Install

npm i remark-lint-relative-markdown-file-path-links

Weekly Downloads

7

Version

0.1.1

License

MIT

Unpacked Size

5.32 kB

Total Files

4

Last publish

Collaborators

  • ricodo