markdown-preferences/no-multiple-empty-lines
disallow multiple empty lines in Markdown files.
- 🔧 The
--fix
option on the command line can automatically fix some of the problems reported by this rule.
📖 Rule Details
This rule helps maintain clean and readable Markdown files by limiting consecutive empty lines, ensuring consistent spacing and a professional appearance. Empty lines within code blocks and frontmatter (YAML, TOML, JSON) are ignored, allowing flexible formatting where needed.
By enforcing this rule, teams can maintain a consistent style in collaborative projects, prevent unnecessary diffs in version control, and ensure documents are easy to navigate.
Practical Scenarios
Organized Documentation: When creating long documents with multiple sections, consistent spacing ensures the structure is easy to follow. This rule eliminates excessive blank lines, making the document more professional and readable.
Improved Collaboration: In collaborative projects, maintaining consistent spacing helps team members quickly understand the document structure, reducing confusion and improving productivity.
Streamlined Reviews: Consistent formatting minimizes unnecessary diffs in version control, making code reviews and document updates more efficient.
<!-- eslint markdown-preferences/no-multiple-empty-lines: 'error' -->
<!-- ✓ GOOD -->
# Heading
Paragraph
Another paragraph
<!-- ✗ BAD (multiple empty lines) -->
# Heading
Paragraph
---
# ✓ GOOD (frontmatter is excluded)
title: Example
---
Paragraph
<!-- eslint markdown-preferences/no-multiple-empty-lines: 'error' -->
<!-- ✓ GOOD (code block is excluded) -->
```
code block
Paragraph
```
🔧 Options
{
"markdown-preferences/no-multiple-empty-lines": [
"error",
{
"max": 1,
"maxEOF": 0,
"maxBOF": 0
}
]
}
max
: Maximum number of consecutive empty lines allowed between content blocks. Default is1
.maxEOF
: Maximum number of consecutive empty lines allowed at the end of the file. Default is0
.maxBOF
: Maximum number of consecutive empty lines allowed at the beginning of the file. Default is0
.
👫 Related Rules
🚀 Version
This rule was introduced in eslint-plugin-markdown-preferences v0.10.0