1- # MDS045 - list-marker-style
1+ ---
2+ id : MDS045
3+ name : list-marker-style
4+ status : ready
5+ description : Unordered list items must use the configured bullet marker character.
6+ ---
7+ # MDS045: list-marker-style
28
3- Enforce consistent bullet character for unordered lists .
9+ Unordered list items must use the configured bullet marker character .
410
5- ## Rationale
11+ ## Settings
612
7- CommonMark accepts three different characters for unordered list
8- markers: ` - ` , ` * ` , and ` + ` . When a codebase mixes these markers,
9- diffs become noisy (changing one marker to another shows up as a
10- change even when the content is identical), and readers may wonder
11- whether the different markers carry semantic meaning.
13+ | Setting | Type | Default | Description |
14+ | ----------| --------------| ----------| -----------------------------------------------------------|
15+ | ` style ` | string | ` "dash" ` | ` "dash" ` (` - ` ), ` "asterisk" ` (` * ` ), or ` "plus" ` (` + ` ) |
16+ | ` nested ` | list(string) | ` [] ` | Per-depth style rotation; cycles by ` depth % len(nested) ` |
1217
13- This rule pins a single marker character project-wide, eliminating
14- the three-way ambiguity and keeping diffs focused on content
15- changes.
18+ ## Config
1619
17- ## Default Configuration
20+ Enable with dash style (the default when enabled):
1821
1922``` yaml
2023rules :
2124 list-marker-style :
22- enabled : false # opt-in
23- style : dash # dash | asterisk | plus
24- nested : [] # optional list for depth rotation
25+ style : dash
2526` ` `
2627
27- The rule is disabled by default. Users must explicitly enable it and
28- choose a style.
29-
30- ## Settings
31-
32- ### ` style`
33-
34- The marker character to use for all unordered lists (when `nested`
35- is empty).
36-
37- - `dash` : Use `-`
38- - `asterisk` : Use `*`
39- - `plus` : Use `+`
28+ Disable (default):
4029
41- # ## `nested`
42-
43- Optional list of style names to cycle through by depth. When set,
44- the marker at depth _n_ is `nested[n % len(nested)]`. Depth 0 is
45- the outermost list.
30+ ` ` ` yaml
31+ rules :
32+ list-marker-style : false
33+ ` ` `
4634
47- Example rotating between dash and asterisk :
35+ Depth-based rotation (outer uses ` -`, inner uses `*`) :
4836
4937` ` ` yaml
5038rules:
@@ -54,69 +42,103 @@ rules:
5442 - asterisk
5543` ` `
5644
57- With this configuration :
58- - Depth 0 (outer) lists use `-`
59- - Depth 1 (nested once) lists use `*`
60- - Depth 2 (nested twice) lists use `-` again
61- - And so on
62-
63- When `nested` is empty (the default), all lists use `style`
64- regardless of depth.
65-
6645# # Examples
6746
68- # ## Good (style: dash)
47+ # ## Good -- dash style
48+
49+ <?include
50+ file : good/dash.md
51+ wrap : markdown
52+ ?>
6953
7054` ` ` markdown
55+ # Good dash marker
56+
57+ This file uses dash markers consistently.
58+
7159- First item
7260- Second item
7361- Third item
74- ` ` `
7562
76- # ## Bad (style: dash)
63+ Nested list:
7764
78- ` ` ` markdown
79- * First item
80- * Second item
81- * Third item
65+ - Outer item
66+ - Inner item
67+ - Another inner item
68+ - Another outer item
8269` ` `
8370
84- The list uses `*` but the configured style is `dash`. The rule will
85- flag this and auto-fix to `-`.
71+ <?/include?>
72+
73+ # ## Good -- nested rotation
8674
87- # ## Good (nested: [dash, asterisk])
75+ <?include
76+ file : good/nested.md
77+ wrap : markdown
78+ ?>
8879
8980` ` ` markdown
81+ # Good nested with rotation
82+
83+ Outer lists use dash, inner use asterisk.
84+
9085- Outer item
9186 * Inner item
9287 * Another inner item
9388- Another outer item
89+ * More inner
90+ - Depth 2 cycles back to dash
91+ * Depth 3 cycles to asterisk
9492` ` `
9593
96- # ## Bad (nested: [dash, asterisk])
94+ <?/include?>
95+
96+ # ## Bad -- wrong marker
97+
98+ <?include
99+ file : bad/asterisk-with-dash.md
100+ wrap : markdown
101+ ?>
97102
98103` ` ` markdown
99- - Outer item
100- - Inner item (should be asterisk)
101- - Another inner item
102- - Another outer item
104+ # Bad asterisk with dash config
105+
106+ This list uses asterisks but dash is configured.
107+
108+ * First item
109+ * Second item
110+ * Third item
103111` ` `
104112
105- The inner list at depth 1 should use `*` but uses `-`.
113+ <?/include?>
114+
115+ # ## Bad -- wrong nested marker
106116
107- # # Interaction with Other Rules
117+ <?include
118+ file : bad/nested-wrong.md
119+ wrap : markdown
120+ ?>
108121
109- - **MDS016 (list-indent)**: Enforces proper indentation of nested
110- lists. MDS045 only controls the marker character, not spacing.
111- - **MDS046 (ordered-list-numbering)**: Applies to ordered lists
112- (numbered ), while MDS045 applies only to unordered lists (bulleted) .
122+ ` ` ` markdown
123+ # Bad nested with wrong inner marker
124+
125+ Outer uses dash (correct ), inner should use asterisk but uses dash .
113126
114- # # Auto-fix
127+ - Outer item
128+ - Inner item should be asterisk
129+ - Another inner item should be asterisk
130+ - Another outer item
131+ ` ` `
115132
116- The rule replaces the marker byte at the start of each list item.
117- Because all three markers (`-`, `*`, `+`) are single bytes, the
118- fix does not affect column alignment or indentation.
133+ <?/include?>
119134
120- # # Category
135+ # # Meta-Information
121136
122- ` list`
137+ - **ID**: MDS045
138+ - **Name**: `list-marker-style`
139+ - **Status**: ready
140+ - **Default**: disabled
141+ - **Fixable**: yes
142+ - **Implementation**:
143+ [source](./)
144+ - **Category**: list
0 commit comments