Skip to content

markdown-preferences/thematic-break-sequence-pattern

enforce consistent repeating patterns for thematic breaks (horizontal rules) in Markdown.

  • ⚙️ This rule is included in plugin.configs.standard.
  • 🔧 The --fix option on the command line can automatically fix some of the problems reported by this rule.

📖 Rule Details

This rule reports thematic breaks (horizontal rules) that do not match the preferred repeating sequence pattern. For example, if the preferred pattern is a sequence of hyphens (---), then space-separated patterns like - - - or -- -- -- will be reported as inconsistent. This helps maintain consistency of thematic break patterns throughout your Markdown documents.

Specifically:

  • If the preferred pattern is a sequence of marks, then --- and ----- are allowed, while - - - and -- -- -- are reported as inconsistent.
  • If the preferred pattern is a repetition of "mark + space", then - - - and - - - - - are allowed, while --- and -- -- -- are reported as inconsistent.

This rule only checks the repeating pattern and ignores the character used (-, *, or _). For example, --- and *** are treated as the same repeating pattern. The character style (which character to use: hyphen, asterisk, or underscore) is checked by the markdown-preferences/thematic-break-character-style rule. For full consistency, use both rules together.

Also, this rule does not check the length (number of repetitions) of the thematic break. For example, if the preferred pattern is "-", both --- and ----- are treated as matching patterns and will not be reported. If you want to control the length of thematic breaks, use the markdown-preferences/thematic-break-length rule. Note that there may be conflicts with the options of the markdown-preferences/thematic-break-length rule. For example, if the preferred pattern is "- ", a minimum length of 5 (- - -) is required, so specifying a length of 3 in the markdown-preferences/thematic-break-length rule may cause a conflict.

md
<!-- eslint markdown-preferences/thematic-break-sequence-pattern: 'error' -->

<!-- ✓ GOOD -->

---

***

___

<!-- ✗ BAD -->

- - -
-- -- --
* * *
_ _ _

🔧 Options

json
{
  "markdown-preferences/thematic-break-sequence-pattern": [
    "error",
    { "pattern": "-" }
  ]
}
  • pattern: The preferred repeating pattern for thematic breaks. It must be a string containing only -, *, _ and spaces.

pattern

Specifies the repeating pattern for thematic breaks. The value must be the minimal repeating pattern, such as "-" or "- ".

For example, if you specify "- - -", any sequence that repeats - - - is allowed, so both - - - and - - -- - - are considered valid.

md
<!-- eslint markdown-preferences/thematic-break-sequence-pattern: ["error", { "pattern": "-" }] -->

<!-- ✓ GOOD -->

---
***
___

<!-- ✗ BAD -->

- - -
* * *
_ _ _
md
<!-- eslint markdown-preferences/thematic-break-sequence-pattern: ["error", { "pattern": "- " }] -->

<!-- ✓ GOOD -->

- - -
* * *
_ _ _

<!-- ✗ BAD -->

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

📚 Further Reading

🚀 Version

This rule was introduced in eslint-plugin-markdown-preferences v0.17.0

🔍 Implementation