markdown-preferences/link-paren-spacing
enforce consistent spacing inside link parentheses
- ⚙️ This rule is included in
plugin.configs.standard. - 🔧 The
--fixoption on the command line can automatically fix some of the problems reported by this rule.
📖 Rule Details
This rule enforces consistent spacing inside the parentheses of links and images in Markdown documents. It helps maintain a uniform style for link and image syntax, improving readability and reducing accidental formatting inconsistencies.
What Does This Rule Check?
- Links: Ensures that there are either always spaces or never spaces just inside the parentheses of link destinations and link titles, according to your configuration.
- Example:
[foo](/url)vs[foo]( /url )
- Example:
- Images: Applies the same rule to image link destinations and image titles (the text inside
![ ... ]).
Why Is This Important?
Consistent parentheses spacing:
- Makes Markdown easier to read and maintain.
- Prevents accidental formatting issues, especially when copying or editing links/images.
- Aligns with team or project style preferences.
How Does It Work?
- By default, the rule is set to
space: "never", disallowing spaces just inside the parentheses. - You can set it to
space: "always"to require spaces inside the parentheses.
When Should You Use This Rule?
- When you want all Markdown links and images to have a consistent parenthesis spacing style.
- When enforcing a style guide for documentation or collaborative writing.
Examples
With never Option (Default)
md
<!-- eslint markdown-preferences/link-paren-spacing: 'error' -->
<!-- ✓ GOOD -->
[foo](/url)

<!-- ✗ BAD -->
[foo]( /url )
With always Option
md
<!-- eslint markdown-preferences/link-paren-spacing: 'error' -->
<!-- ✓ GOOD -->
[foo]( /url )

<!-- ✗ BAD -->
[foo](/url)
🔧 Options
json
{
"markdown-preferences/link-paren-spacing": [
"error",
{
"space": "never"
}
]
}space"never"(Default) - No spaces allowed just inside the parentheses."always"- Spaces required just inside the parentheses.
📚 Further Reading
👫 Related Rules
🚀 Version
This rule was introduced in eslint-plugin-markdown-preferences v0.23.0