markdown/no-invalid-label-refs
Disallow invalid label references
[guide][] is short for [guide][guide]. With whitespace between the last two brackets, it's no longer a reference, and 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-invalid-label-refs": "error" },
},
];It also works with markdown/gfm.
Examples#
example.md1 problem
Read the [guide][ ]Label reference guide is invalid due to white space between [ and ]..
[guide]: https://example.com/guideexample.mdNo problems
Read the [guide][], the [guide], or [this][guide].
[guide]: https://example.com/guide