Skip to content
NewBun 1.4.5 is out. Release notes
AphrodyBun

Linter · Rules

markdown/no-duplicate-definitions

Disallow duplicate definitions

When two definitions have the same label, the first one wins and the others are silently ignored. Links then don't go where the latest edit intended. Labels are compared the way Markdown compares them: case and the amount of whitespace don't matter.

In markdown/gfm the same goes for footnote definitions.

Configure

Off by default. It needs an ESLint config that says which files are in the language:

eslint.config.js
import markdown from "@eslint/markdown";

export default [
  {
    files: ["**/*.md"],
    plugins: { markdown },
    language: "markdown/commonmark",
    rules: { "markdown/no-duplicate-definitions": "error" },
  },
];

It also works with markdown/gfm.

Examples

Reported:

Read the [guide].

[guide]: https://example.com/v1
[Guide]: https://example.com/v2
It is fast.[^1]

[^1]: On Linux.
[^1]: On macOS.

Not reported:

Read the [guide] and the [reference].

[guide]: https://example.com/guide
[reference]: https://example.com/reference

Options

OptionDefaultWhat it does
allowDefinitions["//"]Labels that may be defined more than once.
allowFootnoteDefinitions[]Footnote labels that may be defined more than once.
checkFootnoteDefinitionstrueCheck footnote definitions too.

[//]: # (text) is a common way to write a comment, which is why // is allowed:

[//]: # (First comment)
[//]: # (Second comment)
It is fast.[^1]

[^1]: On Linux.
[^1]: On macOS.