consistent-ordered-list-style
🎨 Stylistic
⭐ CommonMark
🌟 GFM
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
<!-- eslint md/consistent-ordered-list-style: 'error' -->
1. First
3. Second
4. ThirdWith { style: 'one' } Option
<!-- eslint md/consistent-ordered-list-style: ['error', { style: 'one' }] -->
1. First
2. Second
3. ThirdWith { style: 'ordered' } Option
<!-- eslint md/consistent-ordered-list-style: ['error', { style: 'ordered' }] -->
1. First
1. Second
1. ThirdWith { style: 'zero' } Option
<!-- eslint md/consistent-ordered-list-style: ['error', { style: 'zero' }] -->
0. First
1. Second
2. Third✅ Correct
Examples of correct code for this rule:
Default
<!-- eslint md/consistent-ordered-list-style: 'error' -->
1. First
1. Second
1. Third<!-- eslint md/consistent-ordered-list-style: 'error' -->
1. First
2. Second
3. Third<!-- eslint md/consistent-ordered-list-style: 'error' -->
0. First
1. Second
2. ThirdWith { style: 'one' } Option
<!-- eslint md/consistent-ordered-list-style: ['error', { style: 'one' }] -->
1. First
1. Second
1. ThirdWith { style: 'ordered' } Option
<!-- eslint md/consistent-ordered-list-style: ['error', { style: 'ordered' }] -->
1. First
2. Second
3. Third<!-- eslint md/consistent-ordered-list-style: ['error', { style: 'ordered' }] -->
0. First
1. Second
2. ThirdWith { style: 'zero' } Option
<!-- eslint md/consistent-ordered-list-style: ['error', { style: 'zero' }] -->
0. First
0. Second
0. ThirdOptions
'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.