markdown/no-missing-label-refs
Disallow missing label references
[guide] and [the guide][guide] are links only if the document defines guide. If the definition is missing or misspelled, there is no error: the brackets show up in the text.
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-missing-label-refs": "error" },
},
];It also works with markdown/gfm.
Examples#
example.md2 problems
Read the [guideLabel reference guide not found.] and [the reference][refLabel reference ref not found.].example.mdNo problems
Read the [guide] and [the reference][ref]. \[Not a link\]
[guide]: https://example.com/guide
[ref]: https://example.com/referenceOptions#
| Option | Default | What it does |
|---|---|---|
allowLabels | [] | Labels that don't need a definition. |
Use it for text in brackets that was never meant to be a link, like GitHub's alerts:
example.mdwith
{ "allowLabels": ["!NOTE"] }No problems> [!NOTE]
> Restart the server afterwards.