markdown-preferences/ordered-list-marker-style โ
enforce consistent ordered list marker style
- โ๏ธ 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 enforces a consistent ordered list marker style (e.g., always using 1.
, 1)
, or 1.
with a specific delimiter) throughout your Markdown project and restricts which marker styles are allowed. Inconsistent use of ordered list markers can make your documentation harder to read and maintain. This rule helps you enforce a consistent style for ordered list markers across your project, making your Markdown files cleaner and more professional.
Why Use This Rule? โ
Markdown allows different marker styles for ordered lists, such as 1.
, 1)
, etc. Inconsistent use of these markers can make your documentation harder to read and maintain.
Typical use cases:
- You want all ordered lists in your documentation to use the same marker style (e.g., always
1.
). - You want to restrict the allowed marker styles for ordered lists.
- You want to enforce different marker styles for different nesting levels.
How This Rule Works โ
- You can specify which marker styles are allowed and their priority.
- The rule checks that each ordered list uses the correct marker style according to your configuration.
- You can override marker rules for specific nesting levels or parent markers.
- The
--fix
option can automatically correct marker style violations.
<!-- eslint markdown-preferences/ordered-list-marker-style: 'error' -->
<!-- โ GOOD (prefer "n.") -->
1. Item 1
2. Item 2
1) Item 3 <!-- โ GOOD ("n."ใฎ้ฃ็ถใใๅฅใฎใชในใใฎๅ ดๅใฏใใไธใคใฎๅฝขๅผใ่จฑๅฏใใใพใ) -->
2) Item 4
<!-- โ BAD (using "n)" which is not allowed) -->
1) Item 1
2) Item 2
๐ง Options โ
{
"markdown-preferences/ordered-list-marker-style": [
"error",
{
"prefer": "n.",
"overrides": [
{
"level": 2,
"prefer": "n)"
}
]
}
]
}
prefer
: Specifies the prefer marker. Allowed values are"n."
, or"n)"
. This is used for the first list in a sequence or the first list at each level. Default is"n."
.overrides
: Allows you to overrideprefer
for specific list levels or parent marker types. This is an array and can have multiple entries. Default is an empty array ([]
).level
: The list level to override (integer, starting from 1).parentMarker
: The parent list marker to match for the override. Allowed values are"n."
,"n)"
,"any"
, or"bullet"
. If"any"
is specified, it matches to all parent markers. If"bullet"
is specified, it matches to bullet lists (unordered lists). If omitted, applies to all markers for that level (as"any"
).prefer
: The prefer marker for that level.
Examples โ
Specify Different Markers for Level 2 โ
In the following example, "n."
is preferred by default, but for level 2 lists, "n)"
is preferred.
<!-- eslint markdown-preferences/ordered-list-marker-style: [
"error",
{
"prefer": "n.",
"overrides": [
{
"level": 2,
"prefer": "n)"
}
]
}
] -->
<!-- โ GOOD -->
1. Item 1
1) Item 1.1
2) Item 1.2
2. Item 2
1) Item 2.1
2) Item 2.2
1. Item 2.3
2. Item 2.4
<!-- โ BAD -->
1. Item 1
1. Item 1.1
2. Item 1.2
2. Item 2
1. Item 2.1
2. Item 2.2
1) Item 2.3
2) Item 2.4
Specify Different Markers for Level 2 Depending on Parent Marker โ
In the following example, "n."
is preferred by default, but for level 2 lists, if the parent marker is "n."
, then "n)"
is preferred; if the parent marker is "n)"
, then "n."
is preferred.
<!-- eslint markdown-preferences/ordered-list-marker-style: [
"error",
{
"prefer": "n.",
"overrides": [
{
"level": 2,
"parentMarker": "n.",
"prefer": "n)"
},
{
"level": 2,
"parentMarker": "n)",
"prefer": "n."
}
]
}
] -->
<!-- โ GOOD -->
1. Item 1
1) Item 1.1
2) Item 1.2
1. Item 1.3
2. Item 1.4
1) Item 2
1. Item 2.1
2. Item 2.2
1) Item 2.3
2) Item 2.4
<!-- โ BAD -->
1. Item 1
1. Item 1.1
2. Item 1.2
1) Item 1.3
2) Item 1.4
1) Item 2
1) Item 2.1
2) Item 2.2
1. Item 2.3
2. Item 2.4
๐ Further Reading โ
๐ซ Related Rules โ
- markdown-preferences/bullet-list-marker-style
- markdown-preferences/ordered-list-marker-sequence
- markdown-preferences/ordered-list-marker-start
๐ Version โ
This rule was introduced in eslint-plugin-markdown-preferences v0.18.0