markdown/no-empty-definitions
Disallow empty definitions
A definition whose URL is <> or # is a placeholder that nobody came back to. Every link that uses it leads nowhere. In markdown/gfm, a footnote definition with nothing in it, or with nothing but HTML comments, is reported too.
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-empty-definitions": "error" },
},
];It also works with markdown/gfm.
Examples#
example.md2 problems
Read the [guide] and the [reference].
[guide]: <>Unexpected empty definition guide (label: guide) found.
[reference]: #Unexpected empty definition reference (label: reference) found.example.md1 problem
It is fast.[^1]
[^1]:Unexpected empty footnote definition 1 (label: 1) found.example.mdNo problems
Read the [guide].
[guide]: https://example.com/guideOptions#
| Option | Default | What it does |
|---|---|---|
allowDefinitions | ["//"] | Labels whose definition may be empty. |
allowFootnoteDefinitions | [] | Footnote labels whose definition may be empty. |
checkFootnoteDefinitions | true | Check footnote definitions too. |
[//]: # (text) is a common way to write a comment, which is why // is allowed:
example.mdNo problems
[//]: # (This is a comment)example.mdwith
{ "allowDefinitions": ["todo"] }No problems[todo]: #