# 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.

{/* Generated by src/codegen/lint-rule-docs.ts. Do not edit this section. */}

## Configure

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

{/* skip */}

```js 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`.

{/* End of the generated section. */}

## Examples

Reported:

{/* bad */}

```md
Read the [guide].

[guide]: https://example.com/v1
[Guide]: https://example.com/v2
```

{/* bad {"language": "gfm"} */}

```md
It is fast.[^1]

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

Not reported:

{/* good */}

```md
Read the [guide] and the [reference].

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

## Options

| Option                     | Default  | What it does                                            |
| -------------------------- | -------- | ------------------------------------------------------- |
| `allowDefinitions`         | `["//"]` | Labels that may be defined more than once.              |
| `allowFootnoteDefinitions` | `[]`     | Footnote labels that may be defined more than once.     |
| `checkFootnoteDefinitions` | `true`   | Check footnote definitions too.                         |

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

{/* good */}

```md
[//]: # (First comment)
[//]: # (Second comment)
```

{/* good {"language": "gfm", "options": [{ "checkFootnoteDefinitions": false }]} */}

```md
It is fast.[^1]

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