{"id":26277,"library":"remark-lint-no-unused-definitions","title":"remark-lint-no-unused-definitions","description":"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.","status":"active","version":"4.0.2","language":"javascript","source_language":"en","source_url":"https://github.com/remarkjs/remark-lint#main","tags":["javascript","definition","lint","remark","remark-lint","remark-lint-rule","rule","typescript"],"install":[{"cmd":"npm install remark-lint-no-unused-definitions","lang":"bash","label":"npm"},{"cmd":"yarn add remark-lint-no-unused-definitions","lang":"bash","label":"yarn"},{"cmd":"pnpm add remark-lint-no-unused-definitions","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"peer dependency for unified processor","package":"unified","optional":false},{"reason":"required to use remark-lint rules","package":"remark-lint","optional":false}],"imports":[{"note":"ESM-only since v4; CommonJS require will fail.","wrong":"const remarkLintNoUnusedDefinitions = require('remark-lint-no-unused-definitions')","symbol":"remarkLintNoUnusedDefinitions","correct":"import remarkLintNoUnusedDefinitions from 'remark-lint-no-unused-definitions'"},{"note":"The package exports a single default export; named import does not exist.","wrong":"import { remarkLintNoUnusedDefinitions } from 'remark-lint-no-unused-definitions'","symbol":"default","correct":"import remarkLintNoUnusedDefinitions from 'remark-lint-no-unused-definitions'"},{"note":"No extra options; just pass the function to .use().","wrong":"","symbol":"remarkLintNoUnusedDefinitions as a unified plugin","correct":".use(remarkLintNoUnusedDefinitions)"}],"quickstart":{"code":"import { unified } from 'unified';\nimport remarkParse from 'remark-parse';\nimport remarkStringify from 'remark-stringify';\nimport remarkLint from 'remark-lint';\nimport remarkLintNoUnusedDefinitions from 'remark-lint-no-unused-definitions';\nimport { reporter } from 'vfile-reporter';\n\nconst file = await unified()\n  .use(remarkParse)\n  .use(remarkLint)\n  .use(remarkLintNoUnusedDefinitions)\n  .use(remarkStringify)\n  .process('[mercury]: https://example.com/mercury/');\n\nconsole.error(reporter(file));\n// 1:1-1:40: Unexpected unused definition, expected no definition or one or more references to `mercury`","lang":"typescript","description":"Shows how to use the rule: lints a Markdown string with an unused definition, outputting an error message."},"warnings":[{"fix":"Use import syntax instead of require(); upgrade Node.js to 16+.","message":"Package is ESM-only starting from v4.0.0. Node.js 12 no longer supported.","severity":"breaking","affected_versions":">=4.0.0"},{"fix":"Ensure remark-lint is still maintained; consider alternative lint integrations.","message":"The 'remark-lint' package is required but may be deprecated in future in favor of '@mysticatea/remark-lint' or similar.","severity":"deprecated","affected_versions":">=4.0.0"},{"fix":"Combine with remark-lint-no-undefined-references to catch both sides.","message":"The rule does not check references before definitions; it only warns if a definition has zero references.","severity":"gotcha","affected_versions":"*"},{"fix":"Be aware of case-insensitive matching when using GFM footnotes.","message":"Footnotes (GFM) are checked case-insensitively for references; a footnote reference 'mercury' matches definition '[^Mercury]'.","severity":"gotcha","affected_versions":"*"}],"env_vars":null,"last_verified":"2026-05-01T00:00:00.000Z","next_check":"2026-07-30T00:00:00.000Z","problems":[{"fix":"Use import syntax or dynamic import().","cause":"CJS require() used with ESM-only package.","error":"Error [ERR_REQUIRE_ESM]: require() of ES Module ... not supported."},{"fix":"Ensure you are passing the default export directly: .use(remarkLintNoUnusedDefinitions)","cause":"Calling unified().use() with the default imported function incorrectly (e.g., as object instead of function).","error":"TypeError: plugin.use is not a function"},{"fix":"Install remark-lint: npm install remark-lint","cause":"Missing peer dependency 'remark-lint'.","error":"Cannot find module 'remark-lint'"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}