DavidAnson / markdownlint-cli2

A fast, flexible, configuration-based command-line interface for linting Markdown/CommonMark files with the markdownlint library
MIT License
343 stars 46 forks source link

`siblings_only: true` does not work above `######` #339

Closed OlivierZal closed 3 months ago

OlivierZal commented 3 months ago

Hi @DavidAnson ,

The following .markdownlint.jsonc worked until last week:

{
  "no-duplicate-heading": {
    "siblings_only": true
  }
}

but now raises errors:

README.md:979 MD024/no-duplicate-heading Multiple headings with the same content [Context: "###### getTile(select)"]
README.md:985 MD024/no-duplicate-heading Multiple headings with the same content [Context: "###### Parameters"]
README.md:991 MD024/no-duplicate-heading Multiple headings with the same content [Context: "###### Returns"]
README.md:995 MD024/no-duplicate-heading Multiple headings with the same content [Context: "###### Source"]
README.md:1764 MD024/no-duplicate-heading Multiple headings with the same content [Context: "###### getTiles(__namedParamet..."]
README.md:1780 MD024/no-duplicate-heading Multiple headings with the same content [Context: "###### Parameters"]
README.md:1787 MD024/no-duplicate-heading Multiple headings with the same content [Context: "###### Returns"]
README.md:1797 MD024/no-duplicate-heading Multiple headings with the same content [Context: "###### Source"]
DavidAnson commented 3 months ago

The last published release of this project was on April 3, so the problem you report which showed up in the last week is unlikely to be related to this project unless you also changed versions and/or configuration in the last week.

The underlying commit that seems most relevant to what you report is the following, though the perimeter that that was removed is not the one you are using. I can't tell more without additional information from you, though.

https://github.com/DavidAnson/markdownlint/commit/f2725178b1e83b07d7f7cc2db64d42f6aa14b8a1

nschonni commented 3 months ago

Here is another similar example when I regenerated a PR to bump from a rather older version recently https://github.com/canada-ca/ore-ero/pull/1885 That is using an different setting, but also the old file format/name https://github.com/canada-ca/ore-ero/blob/7145452d0e8f8326e0247aa9d8a9316837574226/.markdownlint.json#L4C4-L6

DavidAnson commented 3 months ago

@nschonni, you are using CLI1 in that example, not CLI2 AND you are using the parameter name that was removed. So this is expected.

This passing test case shows the supported siblings_only parameter functioning as documented in relevant versions of the library: https://github.com/DavidAnson/markdownlint/blob/b2305efafb034b1f328845aec9928b5363ffd646/test/heading_duplicate_content_different_nesting.md

Here's the live version of that: https://dlaa.me/markdownlint/#%25m%23%20Change%20log%0A%0A%23%23%202.0.0%0A%0A%23%23%23%20Bug%20fixes%0A%0A%23%23%23%20Features%0A%0A%23%23%201.0.0%0A%0A%23%23%23%20Bug%20fixes%0A%0A%3C!--%20markdownlint-configure-file%20%7B%0A%20%20%22no-duplicate-heading%22%3A%20%7B%0A%20%20%20%20%22siblings_only%22%3A%20true%0A%20%20%7D%0A%7D%20--%3E%0A

If someone has an example of this not working, please share the reproduction steps or repository.

OlivierZal commented 3 months ago

I've also noticed the absence of recent release @DavidAnson: I can't explain why as for now, 8 just know it happens.

nschonni commented 3 months ago

You're right, I just swapped the CLI and upgraded the config. Hiding my previous comment

DavidAnson commented 3 months ago

@OlivierZal, please show how to reproduce the behavior you describe. Otherwise this issue is not actionable.

OlivierZal commented 3 months ago

@DavidAnson, now I can explain.

If I turn siblings_only to false I get more errors:

README.md:19 MD024/no-duplicate-heading Multiple headings with the same content [Context: "#### Enumeration Members"]
README.md:35 MD024/no-duplicate-heading Multiple headings with the same content [Context: "#### Enumeration Members"]
README.md:52 MD024/no-duplicate-heading Multiple headings with the same content [Context: "#### Enumeration Members"]
README.md:88 MD024/no-duplicate-heading Multiple headings with the same content [Context: "#### Enumeration Members"]
README.md:102 MD024/no-duplicate-heading Multiple headings with the same content [Context: "#### Enumeration Members"]
README.md:117 MD024/no-duplicate-heading Multiple headings with the same content [Context: "#### Enumeration Members"]
README.md:131 MD024/no-duplicate-heading Multiple headings with the same content [Context: "#### Enumeration Members"]
README.md:143 MD024/no-duplicate-heading Multiple headings with the same content [Context: "#### Enumeration Members"]
README.md:201 MD024/no-duplicate-heading Multiple headings with the same content [Context: "###### Returns"]
...

So it's new to me because I added last week a lower level of headings, and the issue is that now it raises errors for ###### (and above) although it shouldn't.

OlivierZal commented 3 months ago

About how to reproduce:

nschonni commented 3 months ago

The first warning about getTile(select) is correctly flagging a duplicate heading. There are 2 sections at the same level (siblings). They are trying to document the differences between select being true and false, but the heading is the same for both

OlivierZal commented 3 months ago

Yes @nschonni, but "siblings_only": true should prevent from warning, that's the point. It works well for #### and below but not for ###### and above.

nschonni commented 3 months ago

No, it's a violation because there are duplicates that are siblings at the same heading level, with no breaking heading level between them. https://github.com/DavidAnson/markdownlint/blob/main/doc/md024.md

DavidAnson commented 3 months ago

Nick is correct. All of the violations here are caused by similar groupings at the same heading level (6) as the section they are meant to be in. Everywhere else in the document, Parameters/Returns/Source are one heading level deeper than the section they correspond to. However, in both of the cases being reported, they are at the same level as the section they correspond to. This is probably because heading level 6 is already the maximum, however the rule is correct in flagging these as violations.

OlivierZal commented 3 months ago

The rule is correct but I thought that setting siblings_only to true would have prevent from warning about level 6 in the same way than for level 4.

The README.md is automatically generated by typedoc, so I don't have so much control on it, I'll simply disable the entire rule.

So I close this task. Thanks for the explanations.