markdownlint icon indicating copy to clipboard operation
markdownlint copied to clipboard

no-duplicate-heading: Enable siblings_only by default?

Open JoshuaKGoldberg opened this issue 8 months ago • 3 comments

MD024 / no-duplicate-heading includes a siblings_only property:

https://github.com/DavidAnson/markdownlint/blob/224987d727ebada36752074d2466a061c9e03ff0/doc/Rules.md?plain=1#L806

Is there a reason this is on by default? Duplicate non-sibling headings are not necessarily an issue. For common terms like ## API -> ### (feature) -> #### Examples, it can sometimes make more sense to be consistent with headings across sections.

Example resource discussing how non-sibling duplicates are not necessarily an accessibility issue: https://www.tpgi.com/heading-off-confusion-when-do-headings-fail-wcag

Related issues: #300, #1591

Related comment in the wild: https://github.com/JoshuaKGoldberg/package-json-validator/pull/230#discussion_r2085067204

JoshuaKGoldberg avatar May 12 '25 16:05 JoshuaKGoldberg

That setting did not used to exist and was added in response to the changelog pattern you cite. Because the rule is ultimately about not duplicating headings, the default behavior is to not duplicate ANY headings. For people in the nested scenario, they can opt in.

DavidAnson avatar May 12 '25 17:05 DavidAnson

the default behavior is to not duplicate ANY headings

Can I ask, why? 🙂

As in, what is the set of reasons to enable the rule - and which of those reasons still apply to non-siblings?

JoshuaKGoldberg avatar May 12 '25 17:05 JoshuaKGoldberg

Quoting the documentation:

Rationale: Some Markdown parsers generate anchors for headings based on the heading name; headings with the same content can cause problems with that.

I can't say which parsers, or whether they still have this problem.

DavidAnson avatar May 12 '25 19:05 DavidAnson