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

{/* 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-unused-definitions": "error" },
  },
];
```

It also works with `markdown/gfm`.

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

## Examples

Reported:

{/* bad */}

```md
Read the guide.

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

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

```md
It is fast.

[^1]: On Linux.
```

Not reported:

{/* good */}

```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:

{/* good */}

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

{/* good {"options": [{ "allowDefinitions": ["guide"] }]} */}

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