Skip to content

Commit cba175c

Browse files
committed
fix(md077): accept the indent option instead of reporting it as unknown
The plain `impl_rule_config_methods!` arm derives the rule's known keys by serializing the default config through JSON to TOML, which drops `None` fields. An `Option` key is therefore invisible to the config key validator, so `[MD077] indent = 4` printed "Unknown option for rule MD077: indent" and failed the run under `--deny-config-warnings`, even though the setting was read and applied. The `nullable` arm keeps the key visible to the validator.
1 parent fea6322 commit cba175c

2 files changed

Lines changed: 20 additions & 1 deletion

File tree

‎src/rules/md077_list_continuation_indent.rs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -878,7 +878,7 @@ impl Rule for MD077ListContinuationIndent {
878878
self
879879
}
880880

881-
crate::impl_rule_config_methods!(MD077Config);
881+
crate::impl_rule_config_methods!(MD077Config, nullable);
882882
}
883883

884884
#[cfg(test)]

‎tests/config/documented_alias_reachability_test.rs‎

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,25 @@ fn md013_documented_alias_is_not_reported_as_an_unknown_option() {
104104
);
105105
}
106106

107+
#[test]
108+
fn md077_indent_is_not_reported_as_an_unknown_option() {
109+
// `indent` is `Option<usize>`, and the plain `impl_rule_config_methods!` arm
110+
// serializes the default through JSON->TOML, which drops `None` fields - so
111+
// the key validator never saw it and called a working, documented setting
112+
// unknown. The `nullable` arm keeps it visible.
113+
const LOOSE_ITEM: &str = "# T\n\n- item\n\n wrap\n";
114+
115+
let (baseline, _) = findings_for("MD077", "[MD077]\n", LOOSE_ITEM);
116+
assert_eq!(baseline, 0, "control: 2 spaces is fine without the setting");
117+
118+
let (count, stderr) = findings_for("MD077", "[MD077]\nindent = 4\n", LOOSE_ITEM);
119+
assert_eq!(count, 1, "control: the setting must actually take effect");
120+
assert!(
121+
!stderr.contains("Unknown option"),
122+
"a supported setting must not be reported as unknown, got:\n{stderr}"
123+
);
124+
}
125+
107126
#[test]
108127
fn a_genuinely_unknown_option_is_still_reported() {
109128
// Control: the validator must still catch real typos.

0 commit comments

Comments
 (0)