no-consecutive-blank-line
🎨 Stylistic
🔧 Fixable
⭐ CommonMark
🌟 GFM
Disallow consecutive blank lines.
Rule Details
This rule disallows more than a configured number of consecutive blank lines in Markdown files. Except in a code block, blank lines serve no purpose and do not affect the rendering of content. Consistent blank line usage makes documents easier to scan and avoids accidental large gaps between sections, paragraphs, and list content.
For this rule, a blank line is a line that contains no characters, or contains only spaces and tabs. By default, the rule allows one consecutive blank line and ignores consecutive blank lines inside code blocks.
Examples
❌ Incorrect
Examples of incorrect code for this rule:
Default
<!-- eslint md/no-consecutive-blank-line: 'error' -->
foo
barWith { max: 2 } Option
<!-- eslint md/no-consecutive-blank-line: ['error', { max: 2 }] -->
foo
barWith { skipCode: false } Option
<!-- eslint md/no-consecutive-blank-line: ['error', { skipCode: false }] -->
```js
foo
bar
```With { skipCode: ['js', 'ts'] } Option
<!-- eslint md/no-consecutive-blank-line: ['error', { skipCode: ['js', 'ts'] }] -->
```md
foo
bar
```
```
foo
bar
```✅ Correct
Examples of correct code for this rule:
Default
<!-- eslint md/no-consecutive-blank-line: 'error' -->
foo
bar<!-- eslint md/no-consecutive-blank-line: 'error' -->
```js
foo
bar
```With { max: 2 } Option
<!-- eslint md/no-consecutive-blank-line: ['error', { max: 2 }] -->
foo
barWith { skipCode: true } Option
<!-- eslint md/no-consecutive-blank-line: ['error', { skipCode: true }] -->
```md
foo
bar
```
```
foo
bar
```With { skipCode: ['md', 'txt'] } Option
<!-- eslint md/no-consecutive-blank-line: ['error', { skipCode: ['md', 'txt'] }] -->
```md
foo
bar
```
```txt
baz
qux
```Options
'md/no-consecutive-blank-line': ['error', {
max: 1,
skipCode: true,
}]max
Type:
number/ Default:1
Set the maximum number of consecutive blank lines to allow.
This value must be an integer greater than or equal to 1.
skipCode
Type:
boolean | string[]/ Default:true
true allows consecutive blank lines in all code blocks, while string[] allows consecutive blank lines only in code blocks for the specified languages.
Fix
This rule fixes consecutive blank lines by removing blank lines beyond the configured max value.