Skip to content

no-consecutive-blank-line

🎨 Stylistic 🔧 Fixable ⭐ CommonMark 🌟 GFM

🔗 Rule Source 🔗 Test Source

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 and math blocks when math parsing is enabled.

Examples ​

❌ Incorrect ​

Examples of incorrect code for this rule:

Default ​

md
<!-- eslint md/no-consecutive-blank-line: 'error' -->

foo

bar

With { max: 2 } Option ​

md
<!-- eslint md/no-consecutive-blank-line: ['error', { max: 2 }] -->

foo


bar

With { skipCode: false } Option ​

md
<!-- eslint md/no-consecutive-blank-line: ['error', { skipCode: false }] -->

```js
foo

bar ```

With { skipCode: ['js', 'ts'] } Option ​

md
<!-- eslint md/no-consecutive-blank-line: ['error', { skipCode: ['js', 'ts'] }] -->

```md
foo

bar ``` ``` foo
bar ```

With { skipMath: false } Option ​

md
<!-- eslint md/no-consecutive-blank-line: ['error', { skipMath: false }] -->

$$
foo

bar $$

✅ Correct ​

Examples of correct code for this rule:

Default ​

md
<!-- eslint md/no-consecutive-blank-line: 'error' -->

foo

bar
md
<!-- eslint md/no-consecutive-blank-line: 'error' -->

```js
foo


bar
```

With { max: 2 } Option ​

md
<!-- eslint md/no-consecutive-blank-line: ['error', { max: 2 }] -->

foo


bar

With { skipCode: true } Option ​

md
<!-- eslint md/no-consecutive-blank-line: ['error', { skipCode: true }] -->

```md
foo


bar
```

```
foo


bar
```

With { skipCode: ['md', 'txt'] } Option ​

md
<!-- eslint md/no-consecutive-blank-line: ['error', { skipCode: ['md', 'txt'] }] -->

```md
foo


bar
```

```txt
baz


qux
```

With { skipMath: true } Option ​

md
<!-- eslint md/no-consecutive-blank-line: ['error', { skipMath: true }] -->

$$
foo


bar
$$

Options ​

js
'md/no-consecutive-blank-line': ['error', {
  max: 1,
  skipCode: true,
  skipMath: 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.

skipMath ​

Type: boolean / Default: true

true allows consecutive blank lines in all math blocks.

NOTE

This option requires enabling math parsing with languageOptions: { math: true }.

Fix ​

This rule fixes consecutive blank lines by removing blank lines beyond the configured max value.

Further Reading ​

Prior Art ​