Linter · Rules
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:
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:
Read the guide.
[guide]: https://example.com/guide
It is fast.
[^1]: On Linux.
Not reported:
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:
[//]: # (This is a comment)
[guide]: https://example.com/guide