markdown-preferences/link-title-style
enforce a consistent style for link titles
- ⚙️ 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 titles in Markdown links, images, and link definitions. You can specify the style of the title using double quotes ("title"
), single quotes ('title'
), or parentheses ((title)
). By default, double quotes are enforced. If the title contains the enforced delimiter and avoidEscape
is enabled (default), the rule will not force a change that would require escaping.
Examples
With "double"
Option (Default)
md
<!-- eslint markdown-preferences/link-title-style: 'error' -->
<!-- ✓ GOOD -->
- [example](/url "title")
<!-- ✗ BAD -->
- [example](/url 'title')
- [example](/url (title))
With "single"
Option
md
<!-- eslint markdown-preferences/link-title-style: ["error", { "style": "single" }] -->
<!-- ✓ GOOD -->
- [example](/url 'title')
<!-- ✗ BAD -->
- [example](/url "title")
- [example](/url (title))
With "parentheses"
Option
md
<!-- eslint markdown-preferences/link-title-style: ["error", { "style": "parentheses" }] -->
<!-- ✓ GOOD -->
- [example](/url (title))
<!-- ✗ BAD -->
- [example](/url "title")
- [example](/url 'title')
🔧 Options
json
{
"markdown-preferences/link-title-style": [
"error",
{
"style": "double",
"avoidEscape": true
}
]
}
style
Type: "double" | "single" | "parentheses"
Default: "double"
Specify the style of the link title:
"double"
: Enforce double quotes ("title"
)"single"
: Enforce single quotes ('title'
)"parentheses"
: Enforce parentheses ((title)
)
avoidEscape
Type: boolean
Default: true
If true
, the rule will not enforce a style if it would require escaping the delimiter inside the title.
md
<!-- eslint markdown-preferences/link-title-style: ["error", { "avoidEscape": true }] -->
<!-- ✓ GOOD -->
- [example](/url "title")
- [example](/url '"double" quotes inside single quotes')
- [example](/url ("double" quotes inside parentheses))
<!-- ✗ BAD -->
- [example](/url 'title')
- [example](/url (title))
📚 Further Reading
👫 Related Rules
- markdown-preferences/link-destination-style
- markdown-preferences/link-bracket-newline
- markdown-preferences/link-bracket-spacing
🚀 Version
This rule was introduced in eslint-plugin-markdown-preferences v0.22.0