# markdown/no-unused-definitions

> Disallow unused definitions

A definition that no link or image uses is invisible in the rendered document. It's either left over from text that was removed, or the link that should use it has a typo. 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:

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

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

It also works with `markdown/gfm`.

## Examples

Reported:

```md
Read the guide.

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

```md
It is fast.

[^1]: On Linux.
```

Not reported:

```md
Read the [guide].

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

## Options

| Option                     | Default  | What it does                                     |
| -------------------------- | -------- | ------------------------------------------------ |
| `allowDefinitions`         | `["//"]` | Labels that don't have to be used.               |
| `allowFootnoteDefinitions` | `[]`     | Footnote labels that don't have to be used.      |
| `checkFootnoteDefinitions` | `true`   | Check footnote definitions too.                  |

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

```md
[//]: # (This is a comment)
```

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