[GH-ISSUE #524] Feature Request: markdownlint-disable-line #427

Closed
opened 2026-03-03 01:26:49 +03:00 by kerem · 6 comments
Owner

Originally created by @Zamiell on GitHub (May 9, 2022).
Original GitHub issue: https://github.com/DavidAnson/markdownlint/issues/524

Hello, and thanks for the excellent linter!

Currently, markdownlint has the disable-next-line directive, which is quite a handy feature!

For example, the README.md file gives the following example:

<!-- markdownlint-disable-next-line no-space-in-emphasis -->
deliberate space * in * emphasis

Unfortunately, this not the greatest example, because if you have Prettier installed (which many projects do nowadays), as soon as you hit Ctrl + s in VSCode to save the file, Prettier will automatically reformat it to the following:

<!-- markdownlint-disable-next-line no-space-in-emphasis -->

deliberate space * in * emphasis

And now the comment will no longer apply.

This happened to me earlier today. Being familiar with ESLint, I intuitively knew how to fix the problem, so I tried this:

deliberate space * in * emphasis <!-- markdownlint-disable-line no-space-in-emphasis -->

But unfortunately, that doesn't work, because surprisingly, markdownlint only supports disable-next-line and not disable-line.

Can this please be added?

Originally created by @Zamiell on GitHub (May 9, 2022). Original GitHub issue: https://github.com/DavidAnson/markdownlint/issues/524 Hello, and thanks for the excellent linter! Currently, markdownlint has the `disable-next-line` directive, which is quite a handy feature! For example, the `README.md` file gives the following example: ```md <!-- markdownlint-disable-next-line no-space-in-emphasis --> deliberate space * in * emphasis ``` Unfortunately, this not the greatest example, because if you have Prettier installed (which many projects do nowadays), as soon as you hit `Ctrl + s` in VSCode to save the file, Prettier will automatically reformat it to the following: ```md <!-- markdownlint-disable-next-line no-space-in-emphasis --> deliberate space * in * emphasis ``` And now the comment will no longer apply. This happened to me earlier today. Being familiar with [ESLint](https://eslint.org/), I intuitively knew how to fix the problem, so I tried this: ```md deliberate space * in * emphasis <!-- markdownlint-disable-line no-space-in-emphasis --> ``` But unfortunately, that doesn't work, because surprisingly, markdownlint only supports `disable-next-line` and not `disable-line`. Can this please be added?
kerem 2026-03-03 01:26:49 +03:00
Author
Owner

@DavidAnson commented on GitHub (May 9, 2022):

You can do this with disable/restore as shown in the documentation: https://github.com/DavidAnson/markdownlint#configuration

<!-- gh-comment-id:1121285712 --> @DavidAnson commented on GitHub (May 9, 2022): You can do this with disable/restore as shown in the documentation: https://github.com/DavidAnson/markdownlint#configuration
Author
Owner

@Zamiell commented on GitHub (May 9, 2022):

@DavidAnson Thanks for the quick response.
I see in the docs that it is possible to do disable/restore, but this is pretty cumbersome.
It also is not very DRY - programmers will have to duplicate the code on multiple lines.
It would be better UX and less maintenance for end-users if this linter could also have the disable-line feature, which would allow programmers to specify the directive and associated rule exactly one time.

Other popular linters like ESLint and CSpell have this functionality, so I think it is reasonable for markdownlint to have it too.

<!-- gh-comment-id:1121298871 --> @Zamiell commented on GitHub (May 9, 2022): @DavidAnson Thanks for the quick response. I see in the docs that it is possible to do disable/restore, but this is pretty cumbersome. It also is not very DRY - programmers will have to duplicate the code on multiple lines. It would be better UX and less maintenance for end-users if this linter could also have the `disable-line` feature, which would allow programmers to specify the directive and associated rule exactly one time. Other popular linters like [ESLint](https://eslint.org/) and [CSpell](https://cspell.org/) have this functionality, so I think it is reasonable for `markdownlint` to have it too.
Author
Owner

@DavidAnson commented on GitHub (May 9, 2022):

In my opinion, "next line" is better than "line" because it is clear, it doesn't interfere with the content, and it doesn't risk creating too-long lines. The problem is that Prettier breaks that and needs to be worked around. It would be nice if Prettier were more respectful here, but I can look into adding "line" as an alternative.

<!-- gh-comment-id:1121313958 --> @DavidAnson commented on GitHub (May 9, 2022): In my opinion, "next line" is better than "line" because it is clear, it doesn't interfere with the content, and it doesn't risk creating too-long lines. The problem is that Prettier breaks that and needs to be worked around. It would be nice if Prettier were more respectful here, but I can look into adding "line" as an alternative.
Author
Owner

@Zamiell commented on GitHub (May 9, 2022):

In my opinion, "next line" is better than "line" because it is clear, it doesn't interfere with the content, and it doesn't risk creating too-long lines.

100% agree!

The problem is that Prettier breaks that and needs to be worked around. It would be nice if Prettier were more respectful here

Agreed! But I don't think it would be practical for Prettier to hardcode an array with the names of all of the popular linters out there, and then treat comments with those keywords with special behavior. So it doesn't seem like a problem that Prettier can fix upstream either.

I can look into adding "line" as an alternative.

Thank you!

<!-- gh-comment-id:1121317963 --> @Zamiell commented on GitHub (May 9, 2022): > In my opinion, "next line" is better than "line" because it is clear, it doesn't interfere with the content, and it doesn't risk creating too-long lines. 100% agree! > The problem is that Prettier breaks that and needs to be worked around. It would be nice if Prettier were more respectful here Agreed! But I don't think it would be practical for Prettier to hardcode an array with the names of all of the popular linters out there, and then treat comments with those keywords with special behavior. So it doesn't seem like a problem that Prettier can fix upstream either. > I can look into adding "line" as an alternative. Thank you!
Author
Owner

@DavidAnson commented on GitHub (May 9, 2022):

I know of just one other Markdown linting tool in the Node ecosystem. I think they could handle it if they wanted to. :)

<!-- gh-comment-id:1121323889 --> @DavidAnson commented on GitHub (May 9, 2022): I know of just one other Markdown linting tool in the Node ecosystem. I think they could handle it if they wanted to. :)
Author
Owner

@Zamiell commented on GitHub (May 9, 2022):

Well, what about CSpell? Surely, many people need to spell check their markdown documents. If you're not familiar with it, it has syntax like this:

It is common to misspell the word absence as "absense". <!-- cspell:disable-line absense -->

So that would have to be added as well. And what if some other extension for spell checking started to get more popular than CSpell? Or some other markdown linter got more popular than markdownlint? Should that be added too? I wouldn't be surprised if there were other tools that lint markdown that I'm not personally aware of, so maybe the list could get quite long.

It seems pretty weird for Prettier to be in the business of hard-coding popular tools, as that would be a maintenance burden, especially for a hypothetical niche feature like this.

<!-- gh-comment-id:1121331590 --> @Zamiell commented on GitHub (May 9, 2022): Well, what about CSpell? Surely, many people need to spell check their markdown documents. If you're not familiar with it, it has syntax like this: ```md It is common to misspell the word absence as "absense". <!-- cspell:disable-line absense --> ``` So that would have to be added as well. And what if some other extension for spell checking started to get more popular than CSpell? Or some other markdown linter got more popular than markdownlint? Should that be added too? I wouldn't be surprised if there were other tools that lint markdown that I'm not personally aware of, so maybe the list could get quite long. It seems pretty weird for Prettier to be in the business of hard-coding popular tools, as that would be a maintenance burden, especially for a hypothetical niche feature like this.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/markdownlint#427
No description provided.