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

remark-lint-no-duplicate-definitions

JSON →
library4.0.1jsnpmunverified

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.

npm install remark-lint-no-duplicate-definitions
INSTALL
IMPORT
SIG · REMARK-LINT-NO-DUP
R
remark-lint-no-duplicate-definitions
testingjavascriptv4.0.1
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.

remarkLintNoDuplicateDefinitions
import remarkLintNoDuplicateDefinitions from 'remark-lint-no-duplicate-definitions'
import { remarkLintNoDuplicateDefinitions } from 'remark-lint-no-duplicate-definitions'
Default export is a function. Named import will fail; the package exports no named symbols.
remarkLintNoDuplicateDefinitions (CommonJS)
const remarkLintNoDuplicateDefinitions = require('remark-lint-no-duplicate-definitions')
const { default: remarkLintNoDuplicateDefinitions } = require('remark-lint-no-duplicate-definitions')
Package is ESM-only since v4. In Node.js with require() you need to use dynamic import() or set type to module.
TypeScript types
import remarkLintNoDuplicateDefinitions from 'remark-lint-no-duplicate-definitions' // types inferred
import type { remarkLintNoDuplicateDefinitions } from 'remark-lint-no-duplicate-definitions'
No explicit type exports; types are bundled. Use the import as normal and TypeScript will pick up the types.

Demonstrates how to use the rule to detect duplicate definitions. The input has two identical identifiers (mercury) and the output will show a warning.

import { unified } from 'unified' import remarkParse from 'remark-parse' import remarkLint from 'remark-lint' import remarkLintNoDuplicateDefinitions from 'remark-lint-no-duplicate-definitions' import remarkStringify from 'remark-stringify' import { reporter } from 'vfile-reporter' const file = await unified() .use(remarkParse) .use(remarkLint) .use(remarkLintNoDuplicateDefinitions) .use(remarkStringify) .process('[mercury]: https://example.com/mercury/\n[mercury]: https://example.com/venus/') console.error(reporter(file))
Debug
Known issues
breakingPackage is now ESM-only. Requires Node.js 16+ and cannot be required with CommonJS require() directly.
fix
Use import syntax or dynamic import(). If you must use require, set type: module in package.json or use .mjs extension.
affects: >=4.0.0
deprecatedThe previous option allowDuplicates is removed in v4. The rule now always warns on duplicates.
fix
If you need to allow duplicates, consider using a custom rule or ignore messages via remark-lint options.
affects: >=4.0.0
gotchaThe rule does not check cross-case duplicates. Identifiers are case-sensitive.
fix
Ensure identifiers match exactly. If you need case-insensitive checking, use a custom rule or additional linting.
affects: *
gotchaThe rule only checks definitions, not references. Defining the same identifier multiple times will warn, but references are not validated.
fix
Use remark-lint-no-undefined-references to catch missing definitions, and ensure uniqueness via this rule.
affects: *
Errors
Common errors & fixes
Unexpected definition with an already defined identifier (`mercury`), expected unique identifiers
The same identifier is defined more than once in the Markdown document.
fix
Remove duplicate definitions or rename one of the identifiers to be unique.
TypeError: remarkLintNoDuplicateDefinitions is not a function
Using named import instead of default import.
fix
Use `import remarkLintNoDuplicateDefinitions from 'remark-lint-no-duplicate-definitions'` (no curly braces).
ERR_REQUIRE_ESM: require() of ES Module not supported
Trying to require() the package in a CommonJS context.
fix
Use dynamic import() or switch to ESM (e.g., set type: module in package.json).
Upgrade
Version history
4.0.1latest on npm
Audit
Dependencies
unifiedrequiredUsed as the core processor; the plugin is a unified transformer.
remark-lintrequiredRequired to configure and report lint messages.
remark-parseoptionalNeeded to parse Markdown into an AST for linting.
remark-stringifyoptionalOptional but commonly used in conjunction for processing.
Agent activity
2 hits · last 30 days
node
2
Resources
remark-lint-no-duplicate-definitions — npm install remark-lint-no-duplicate-definitions · libregistry