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]: <>
[reference]: #
example.md1 problem
It is fast.[^1]

[^1]:
example.mdNo problems
Read the [guide].

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

Options#

OptionDefaultWhat it does
allowDefinitions["//"]Labels whose definition may be empty.
allowFootnoteDefinitions[]Footnote labels whose definition may be empty.
checkFootnoteDefinitionstrueCheck 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]: #