remark-lint-no-undefined-references

raw JSON →
5.0.2 verified Fri May 01 auth: no javascript

remark-lint rule to warn when Markdown references to undefined definitions are found. Current stable version: 5.0.2. Released as part of the remark-lint monorepo; patch updates follow release cadence of the monorepo. Differentiator: catches broken links in Markdown documents by ensuring all `[text][reference]` and `[text][]` references have a corresponding `[reference]: URL` definition. Supports options to allow shortcut references and custom allow-lists. Ships TypeScript types and is ESM-only from v5.

error Error: Cannot find module 'remark-lint-no-undefined-references'
cause Package not installed or incorrect import path.
fix
npm install remark-lint-no-undefined-references
error TypeError: remarkLintNoUndefinedReferences is not a function
cause Using named import instead of default import in ESM.
fix
Use import remarkLintNoUndefinedReferences from 'remark-lint-no-undefined-references' (no braces).
breaking Package is now ESM-only. CJS require() no longer works without .default.
fix Use dynamic import() or require('...').default if using CommonJS.
deprecated Options allowShortcutLink default changed from true to false in v5.
fix Set allowShortcutLink: true explicitly if you need the old behavior.
breaking Node.js version requirement raised to 16+.
fix Upgrade Node.js to 16 or later.
gotcha The rule does not check inline links like [text](url) or images ![alt](url) — only reference-style links.
fix Use remark-lint-no-undefined-references only for reference links; for other link checks use additional rules.
npm install remark-lint-no-undefined-references
yarn add remark-lint-no-undefined-references
pnpm add remark-lint-no-undefined-references

Sets up a unified pipeline to lint a Markdown file for undefined references, allowing shortcut links.

import { unified } from 'unified'
import remarkParse from 'remark-parse'
import remarkStringify from 'remark-stringify'
import remarkLint from 'remark-lint'
import remarkLintNoUndefinedReferences from 'remark-lint-no-undefined-references'
import { read } from 'to-vfile'
import { reporter } from 'vfile-reporter'

const file = await read('example.md')

await unified()
  .use(remarkParse)
  .use(remarkLint)
  .use(remarkLintNoUndefinedReferences, { allowShortcutLink: true })
  .use(remarkStringify)
  .process(file)

console.error(reporter(file))