DavidAnson / vscode-markdownlint

Markdown linting and style checking for Visual Studio Code
https://marketplace.visualstudio.com/items?itemName=DavidAnson.vscode-markdownlint
MIT License
897 stars 166 forks source link

`"default": true` in `.markdownlint.jsonc` not respected #281

Closed simensol closed 1 year ago

simensol commented 1 year ago

According to the documentation:

The default rule configuration disables MD013/line-length because many files include lines longer than the conventional 80 character limit

However, if I create the following .markdownlint.jsonc file:

{
    "default": true
}

markdownlint still complains about MD013/line-length. If I change the .markdownlint.jsonc file to:

{
    "MD013": false
}

the linting error disappears. It seems that the "default": true in .markdownlint.jsonc is not respected?

DavidAnson commented 1 year ago

You're mixing two things here. :) In the library, all rules default to enabled and that property can be used to default them all to disabled. It works for that purpose as you demonstrate. In the VS Code plug-in, the MD013 rule is disabled by default to avoid being distracting in documents that have many long lines. However, if you manually configure all rules to be enabled as you are doing, then MD013 is enabled as well and it will report issues as you see.

simensol commented 1 year ago

It makes perfectly sense! Thanks for explaining :)

simensol commented 1 year ago

If MD013 is disabled by default, an empty .markdownlint.jsonc shouldn't report any MD013 issues, right? When I have this .markdownlint.jsonc:

{
}

markdownlint raises MD013 and I have to set

{
    "MD013": false
}

to make the linting errors disappear.

DavidAnson commented 1 year ago

From what I can tell, reading the code on my phone, the extension is doing the expected thing by passing MD013:false to CLI2 as the default. However, CLI2 behavior (by design) is that any .markdownlint.json file replaces whatever configuration was present up to that point and so the empty configuration there takes over and all rules start enabled.

I don't think this is something I want to change because this notion of "custom default" is only used by the extension to avoid scaring new people away or making long-lined projects unfriendly. Once someone has created their own configuration file, the assumption is that they will use it to configure things however they like.

A project should lint consistently for users of the extension, CLI2, CLI, etc. and propagating this editor default would break that by toggling MD013 "randomly" for users.

simensol commented 1 year ago

Thanks for explaining—again it makes perfectly sense :) I guess I got confused by the "default rule configuration" sentence, and I didn't grasp (until now) that an empty .markdownlint.json actually replaces any "default rule configuration".

DavidAnson commented 1 year ago

No worries. There are other behaviors that make sense as well, but this is the behavior I ended up with. :)