markdown-preferences/link-destination-style
enforce a consistent style for link destinations
- ⚙️ This rule is included in
plugin.configs.standard
. - 🔧 The
--fix
option on the command line can automatically fix some of the problems reported by this rule.
📖 Rule Details
This rule enforces a consistent style for link destinations (the URL part of links, images, and link definitions) in Markdown. You can specify the style of the destination as either bare (e.g. /url
) or pointy-bracketed (e.g. </url>
). By default, bare style is enforced. If the destination contains characters that require escaping and avoidEscape
is enabled (default), the rule will not force a change that would require escaping.
Examples
With "bare"
Option (Default)
<!-- eslint markdown-preferences/link-destination-style: 'error' -->
<!-- ✓ GOOD -->
- [foo](/bare-url)
- [foo](/bare-url 'with title')
- 
[ref]: /bare-url
<!-- ✗ BAD -->
- [foo](</pointy-bracketed-url>)
- 
[ref]: </pointy-bracketed-url>
With "pointy-brackets"
Option
<!-- eslint markdown-preferences/link-destination-style: ["error", { "style": "pointy-brackets" }] -->
<!-- ✓ GOOD -->
- [foo](</pointy-bracketed-url>)
- [foo](</pointy-bracketed-url> 'with title')
- 
[ref]: </pointy-bracketed-url>
<!-- ✗ BAD -->
- [foo](/bare-url)
- 
[ref]: /bare-url
🔧 Options
{
"markdown-preferences/link-destination-style": [
"error",
{
"style": "bare",
"avoidEscape": true
}
]
}
style
Type: "bare" | "pointy-brackets"
Default: "bare"
Specify the style of the link destination:
"bare"
: Enforce bare destinations (e.g./url
)"pointy-brackets"
: Enforce pointy-bracketed destinations (e.g.</url>
)
avoidEscape
Type: boolean
Default: true
If true
, the rule will not enforce a style if it would require escaping whitespace, control characters, or unbalanced parentheses in the destination.
<!-- eslint markdown-preferences/link-destination-style: ["error", { "avoidEscape": true }] -->
<!-- ✓ GOOD -->
- [foo](/bare-url)
- [foo](</pointy-bracketed-url with space>)
- [foo](</pointy-bracketed-url(with)unbalanced)parentheses>)
<!-- ✗ BAD -->
- [foo](</pointy-bracketed-url>)
- [foo](</pointy-bracketed-url(with)(balanced)parentheses>)
📚 Further Reading
👫 Related Rules
- markdown-preferences/link-title-style
- markdown-preferences/link-bracket-newline
- markdown-preferences/link-bracket-spacing
🚀 Version
This rule was introduced in eslint-plugin-markdown-preferences v0.22.0