Skip to content

consistent-unordered-list-style

🎨 Stylistic 🔧 Fixable ⭐ CommonMark 🌟 GFM

🔗 Rule Source 🔗 Test Source

Enforce consistent unordered list style.

Rule Details ​

This rule enforces a single, consistent style for unordered list markers in Markdown files. Consistent formatting makes it easier to understand a document, and mixing different unordered list styles can reduce readability.

An unordered list marker can be - (dash), * (asterisk), or + (plus). 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 md/consistent-unordered-list-style: 'error' -->

- item 1
*
item 2
+
item 3

With { style: '-' } Option ​

md
<!-- eslint md/consistent-unordered-list-style: ['error', { style: '-' }] -->

*
item 1
+
item 2

With { style: '*' } Option ​

md
<!-- eslint md/consistent-unordered-list-style: ['error', { style: '*' }] -->

-
item 1
+
item 2

With { style: '+' } Option ​

md
<!-- eslint md/consistent-unordered-list-style: ['error', { style: '+' }] -->

-
item 1
*
item 2

With { style: 'sublist' } Option ​

md
<!-- eslint md/consistent-unordered-list-style: ['error', { style: 'sublist' }] -->

- depth 0 item
  
-
depth 1 item
* depth 2 item
+
depth 0 item
+ depth 1 item
-
depth 2 item

✅ Correct ​

Examples of correct code for this rule:

Default ​

md
<!-- eslint md/consistent-unordered-list-style: 'error' -->

- item 1
- item 2
- item 3
md
<!-- eslint md/consistent-unordered-list-style: 'error' -->

* item 1
* item 2
* item 3
md
<!-- eslint md/consistent-unordered-list-style: 'error' -->

+ item 1
+ item 2
+ item 3

With { style: '-' } Option ​

md
<!-- eslint md/consistent-unordered-list-style: ['error', { style: '-' }] -->

- item 1
- item 2

With { style: '*' } Option ​

md
<!-- eslint md/consistent-unordered-list-style: ['error', { style: '*' }] -->

* item 1
* item 2

With { style: '+' } Option ​

md
<!-- eslint md/consistent-unordered-list-style: ['error', { style: '+' }] -->

+ item 1
+ item 2

With { style: 'sublist' } Option ​

md
<!-- eslint md/consistent-unordered-list-style: ['error', { style: 'sublist' }] -->

- depth 0 item
  + depth 1 item
    * depth 2 item

- depth 0 item
  + depth 1 item
    * depth 2 item

Options ​

js
'md/consistent-unordered-list-style': ['error', {
  style: 'consistent',
}]

style ​

Type: 'consistent' | 'sublist' | '-' | '*' | '+' / Default: 'consistent'

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

When style is set to 'sublist', the rule enforces that all unordered list markers in sublists use a consistent symbol that differs from that of their parent list, depending on the nesting depth.

You can also specify a particular style by setting style to '-', '*', or '+', which will enforce that all unordered list markers use the specified style.

Fix ​

This rule fixes the unordered list markers by replacing them with the configured style.

Prior Art ​