DavidAnson / markdownlint

A Node.js style checker and lint tool for Markdown/CommonMark files.
MIT License
4.72k stars 716 forks source link

Specify per-rule severity (warning vs. error) #254

Open t-rad679 opened 4 years ago

t-rad679 commented 4 years ago

Hello!

I can't seem to find a way to specify severity for rules, or even the entire config as a whole. I'd like to make it so only certain rules produce a non-zero exit code if they fail. Is there a way to do this presently, and, if not, can we add one?

DavidAnson commented 4 years ago

This is an issue for the CLI repository: https://github.com/igorshubovych/markdownlint-cli

Unfortunately, I cannot transfer it, so please open this there instead.

There is not currently a notion of “warnings“ in the tool. General best practice around development tools is to set “warnings as errors“, so I’m not sure this is something I want to add. What is the scenario?

t-rad679 commented 4 years ago

I have one rule for markdownlint I'd like for engineers to be aware of, but I don't want our pre-merge lint checks to fail and prevent submission...Specifically the inline html rule. The other rules I'd like to fail (return non-zero exit status). In general, I think this is a pretty useful feature that most linters have and I was just a little surprised it didn't exist here.

I could see how providing this option for the ruleset as a whole could be solved in the CLI, but it doesn't seem optimal to solve it per-rule there. You could do it with command line options, but I feel like it would be cleaner to include a configuration option for it on every rule, and possibly the ability to set a global default that can be overridden per rule. I can also file a ticket with the CLI project, but that does seem less practical to me.

DavidAnson commented 4 years ago

Could you run two passes? The first has the rules you care to enforce and will fail the build. The second has rules you expect people to ignore and doesn’t fail the build.

t-rad679 commented 4 years ago

That works. It seems kind of like a hack, but I'm sure you have a lot going on and need to prioritize. I get that some less important requests, more time-consuming requests, or requests that have workarounds, might not realistically be gotten to.

I do think the feature this issue is requesting is pretty standard and useful for linting tools, though. With the exception of Prettier (which is very opinionated and ONLY performs fixes; it does not just do checks under any circumstances. We mostly use it for JSON config files.), all of our other linters (ESLint, Stylelint, Checkstyle, the Eclipse formatter used with Spotless, and remark.js) have a concept of warn vs error for each rule.

Thank you for your help!