Skip to content

consistent-thematic-break-style

🎨 Stylistic 🔧 Fixable ⭐ CommonMark 🌟 GFM

🔗 Rule Source 🔗 Test Source

Enforce consistent thematic break style.

Rule Details

This rule enforces a single, consistent style for thematic breaks (horizontal rules) in Markdown files. Consistent formatting makes it easier to understand a document, and mixing different thematic break styles can reduce readability.

A thematic break is defined as a line that contains only a *, -, or _ character repeated at least three times, optionally separated by spaces or tabs. While Markdown allows any of these styles, this rule ensures that only one is used throughout the document.

Examples

❌ Incorrect

Examples of incorrect code for this rule:

Default

md
<!-- eslint mark/consistent-thematic-break-style: "error" -->

---
- - -
***
* * *
****
___
md
<!-- eslint mark/consistent-thematic-break-style: "error" -->

***
* * *
****
___
---
- - -
md
<!-- eslint mark/consistent-thematic-break-style: "error" -->

___
---
- - -
***
* * *
****

With { style: '- - -' } Option

md
<!-- eslint mark/consistent-thematic-break-style: ["error", { style: '- - -' }] -->

---
***
___

✅ Correct

Examples of correct code for this rule:

Default

md
<!-- eslint mark/consistent-thematic-break-style: "error" -->

---
---
---
md
<!-- eslint mark/consistent-thematic-break-style: "error" -->

***
***
***
md
<!-- eslint mark/consistent-thematic-break-style: "error" -->

___
___
___

With { style: '- - -' } Option

md
<!-- eslint mark/consistent-thematic-break-style: ["error", { style: '- - -' }] -->

- - -
- - -
- - -

Options

js
'mark/consistent-thematic-break-style': ['error', {
  style: 'consistent',
}]

style

Type: string / Default: 'consistent'

When style is set to 'consistent', the rule enforces that all thematic breaks in the document use the same style as the first one encountered.

You can also specify a particular style by setting style to '---', '***', '___', or any other string value, which will enforce that all thematic breaks use the specified style.

Fix

This rule fixes the thematic breaks by replacing them with the configured style.

Prior Art