Registry / testing / remark-lint-no-unused-definitions

remark-lint-no-unused-definitions

JSON →
library4.0.2jsnpmunverified

A remark-lint rule that warns when definitions are not referenced in the document. Current version 4.0.2, part of the remark-lint monorepo, released as ESM-only. Differentiators: catches dead code (unused link/image/footnote definitions) to keep Markdown clean. Works with remark-gfm for footnotes. No options. Part of the recommended preset.

npm install remark-lint-no-unused-definitions
INSTALL
IMPORT
SIG · REMARK-LINT-NO-UNU
R
remark-lint-no-unused-definitions
testingjavascriptv4.0.2
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

remarkLintNoUnusedDefinitions
import remarkLintNoUnusedDefinitions from 'remark-lint-no-unused-definitions'
const remarkLintNoUnusedDefinitions = require('remark-lint-no-unused-definitions')
ESM-only since v4; CommonJS require will fail.
default
import remarkLintNoUnusedDefinitions from 'remark-lint-no-unused-definitions'
import { remarkLintNoUnusedDefinitions } from 'remark-lint-no-unused-definitions'
The package exports a single default export; named import does not exist.
remarkLintNoUnusedDefinitions as a unified plugin
.use(remarkLintNoUnusedDefinitions)
No extra options; just pass the function to .use().

Shows how to use the rule: lints a Markdown string with an unused definition, outputting an error message.

import { unified } from 'unified'; import remarkParse from 'remark-parse'; import remarkStringify from 'remark-stringify'; import remarkLint from 'remark-lint'; import remarkLintNoUnusedDefinitions from 'remark-lint-no-unused-definitions'; import { reporter } from 'vfile-reporter'; const file = await unified() .use(remarkParse) .use(remarkLint) .use(remarkLintNoUnusedDefinitions) .use(remarkStringify) .process('[mercury]: https://example.com/mercury/'); console.error(reporter(file)); // 1:1-1:40: Unexpected unused definition, expected no definition or one or more references to `mercury`
Debug
Known issues
breakingPackage is ESM-only starting from v4.0.0. Node.js 12 no longer supported.
fix
Use import syntax instead of require(); upgrade Node.js to 16+.
affects: >=4.0.0
deprecatedThe 'remark-lint' package is required but may be deprecated in future in favor of '@mysticatea/remark-lint' or similar.
fix
Ensure remark-lint is still maintained; consider alternative lint integrations.
affects: >=4.0.0
gotchaThe rule does not check references before definitions; it only warns if a definition has zero references.
fix
Combine with remark-lint-no-undefined-references to catch both sides.
affects: *
gotchaFootnotes (GFM) are checked case-insensitively for references; a footnote reference 'mercury' matches definition '[^Mercury]'.
fix
Be aware of case-insensitive matching when using GFM footnotes.
affects: *
Errors
Common errors & fixes
Error [ERR_REQUIRE_ESM]: require() of ES Module ... not supported.
CJS require() used with ESM-only package.
fix
Use import syntax or dynamic import().
TypeError: plugin.use is not a function
Calling unified().use() with the default imported function incorrectly (e.g., as object instead of function).
fix
Ensure you are passing the default export directly: .use(remarkLintNoUnusedDefinitions)
Cannot find module 'remark-lint'
Missing peer dependency 'remark-lint'.
fix
Install remark-lint: npm install remark-lint
Upgrade
Version history
4.0.2latest on npm
Audit
Dependencies
unifiedrequiredpeer dependency for unified processor
remark-lintrequiredrequired to use remark-lint rules
Agent activity
4 hits · last 30 days
node
4
Resources
remark-lint-no-unused-definitions — npm install remark-lint-no-unused-definitions · libregistry