Skip to content

consistent-ordered-list-style

🎨 Stylistic ⭐ CommonMark 🌟 GFM

🔗 Rule Source 🔗 Test Source

Enforce consistent ordered list style.

Rule Details ​

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

Ordered list items can use the same number for every item or increase sequentially. The less common style of starting with 0 is also supported.

Examples ​

❌ Incorrect ​

Examples of incorrect code for this rule:

Default ​

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

1. First
3
. Second
4
. Third

With { style: 'one' } Option ​

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

1. First
2
. Second
3
. Third

With { style: 'ordered' } Option ​

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

1. First
1
. Second
1
. Third

With { style: 'zero' } Option ​

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

0. First
1
. Second
2
. Third

✅ Correct ​

Examples of correct code for this rule:

Default ​

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

1. First
1. Second
1. Third
md
<!-- eslint md/consistent-ordered-list-style: 'error' -->

1. First
2. Second
3. Third
md
<!-- eslint md/consistent-ordered-list-style: 'error' -->

0. First
1. Second
2. Third

With { style: 'one' } Option ​

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

1. First
1. Second
1. Third

With { style: 'ordered' } Option ​

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

1. First
2. Second
3. Third
md
<!-- eslint md/consistent-ordered-list-style: ['error', { style: 'ordered' }] -->

0. First
1. Second
2. Third

With { style: 'zero' } Option ​

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

0. First
0. Second
0. Third

Options ​

js
'md/consistent-ordered-list-style': ['error', {
  style: 'one-or-ordered',
}]

style ​

Type: 'one-or-ordered' | 'one' | 'ordered' | 'zero' / Default: 'one-or-ordered'

When style is set to 'one-or-ordered', the rule allows either the 'one' or 'ordered' style based on the first two list item prefixes.

When style is set to 'one', the rule requires every prefix to be 1.

When style is set to 'ordered', the rule requires prefixes to increase sequentially, starting from 1 or from 0 when the list has two or more items.

When style is set to 'zero', the rule requires every prefix to be 0.

Prior Art ​