{"id":26245,"library":"remark-lint-no-duplicate-definitions","title":"remark-lint-no-duplicate-definitions","description":"A remark-lint rule that warns when identifiers (footnotes, links, etc.) are defined multiple times in Markdown documents. Current stable version is 4.0.1 (ESM-only, requires Node.js 16+). Part of the remark-lint ecosystem, included in `remark-preset-lint-recommended`. It helps catch mistakes where the same identifier is used for different definitions, ensuring uniqueness. Unlike custom checks, this rule integrates seamlessly with remark's unified pipeline and provides clear, standardized error messages.","status":"active","version":"4.0.1","language":"javascript","source_language":"en","source_url":"https://github.com/remarkjs/remark-lint#main","tags":["javascript","definition","duplicate","lint","remark","remark-lint","remark-lint-rule","rule","typescript"],"install":[{"cmd":"npm install remark-lint-no-duplicate-definitions","lang":"bash","label":"npm"},{"cmd":"yarn add remark-lint-no-duplicate-definitions","lang":"bash","label":"yarn"},{"cmd":"pnpm add remark-lint-no-duplicate-definitions","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Used as the core processor; the plugin is a unified transformer.","package":"unified","optional":false},{"reason":"Required to configure and report lint messages.","package":"remark-lint","optional":false},{"reason":"Needed to parse Markdown into an AST for linting.","package":"remark-parse","optional":true},{"reason":"Optional but commonly used in conjunction for processing.","package":"remark-stringify","optional":true}],"imports":[{"note":"Default export is a function. Named import will fail; the package exports no named symbols.","wrong":"import { remarkLintNoDuplicateDefinitions } from 'remark-lint-no-duplicate-definitions'","symbol":"remarkLintNoDuplicateDefinitions","correct":"import remarkLintNoDuplicateDefinitions from 'remark-lint-no-duplicate-definitions'"},{"note":"Package is ESM-only since v4. In Node.js with require() you need to use dynamic import() or set type to module.","wrong":"const { default: remarkLintNoDuplicateDefinitions } = require('remark-lint-no-duplicate-definitions')","symbol":"remarkLintNoDuplicateDefinitions (CommonJS)","correct":"const remarkLintNoDuplicateDefinitions = require('remark-lint-no-duplicate-definitions')"},{"note":"No explicit type exports; types are bundled. Use the import as normal and TypeScript will pick up the types.","wrong":"import type { remarkLintNoDuplicateDefinitions } from 'remark-lint-no-duplicate-definitions'","symbol":"TypeScript types","correct":"import remarkLintNoDuplicateDefinitions from 'remark-lint-no-duplicate-definitions' // types inferred"}],"quickstart":{"code":"import { unified } from 'unified'\nimport remarkParse from 'remark-parse'\nimport remarkLint from 'remark-lint'\nimport remarkLintNoDuplicateDefinitions from 'remark-lint-no-duplicate-definitions'\nimport remarkStringify from 'remark-stringify'\nimport { reporter } from 'vfile-reporter'\n\nconst file = await unified()\n  .use(remarkParse)\n  .use(remarkLint)\n  .use(remarkLintNoDuplicateDefinitions)\n  .use(remarkStringify)\n  .process('[mercury]: https://example.com/mercury/\\n[mercury]: https://example.com/venus/')\n\nconsole.error(reporter(file))","lang":"typescript","description":"Demonstrates how to use the rule to detect duplicate definitions. The input has two identical identifiers (mercury) and the output will show a warning."},"warnings":[{"fix":"Use import syntax or dynamic import(). If you must use require, set type: module in package.json or use .mjs extension.","message":"Package is now ESM-only. Requires Node.js 16+ and cannot be required with CommonJS require() directly.","severity":"breaking","affected_versions":">=4.0.0"},{"fix":"If you need to allow duplicates, consider using a custom rule or ignore messages via remark-lint options.","message":"The previous option allowDuplicates is removed in v4. The rule now always warns on duplicates.","severity":"deprecated","affected_versions":">=4.0.0"},{"fix":"Ensure identifiers match exactly. If you need case-insensitive checking, use a custom rule or additional linting.","message":"The rule does not check cross-case duplicates. Identifiers are case-sensitive.","severity":"gotcha","affected_versions":"*"},{"fix":"Use remark-lint-no-undefined-references to catch missing definitions, and ensure uniqueness via this rule.","message":"The rule only checks definitions, not references. Defining the same identifier multiple times will warn, but references are not validated.","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":"Remove duplicate definitions or rename one of the identifiers to be unique.","cause":"The same identifier is defined more than once in the Markdown document.","error":"Unexpected definition with an already defined identifier (`mercury`), expected unique identifiers"},{"fix":"Use `import remarkLintNoDuplicateDefinitions from 'remark-lint-no-duplicate-definitions'` (no curly braces).","cause":"Using named import instead of default import.","error":"TypeError: remarkLintNoDuplicateDefinitions is not a function"},{"fix":"Use dynamic import() or switch to ESM (e.g., set type: module in package.json).","cause":"Trying to require() the package in a CommonJS context.","error":"ERR_REQUIRE_ESM: require() of ES Module not supported"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}