[GH-ISSUE #5] Add ability to disable specific rule(s) for specific file(s) #2

Closed
opened 2026-03-03 01:22:54 +03:00 by kerem · 7 comments
Owner

Originally created by @IanVS on GitHub (Aug 28, 2015).
Original GitHub issue: https://github.com/DavidAnson/markdownlint/issues/5

Hello, I'm working on the ESLint project, which uses this module. In general, we want to prohibit tabs in our markdown (using rule MD010), but there is one file where I need to use tabs in an example of the indent rule. Is there a way to turn off just that rule, for just that file? If not, is that a feature you would consider adding?

Originally created by @IanVS on GitHub (Aug 28, 2015). Original GitHub issue: https://github.com/DavidAnson/markdownlint/issues/5 Hello, I'm working on the ESLint project, which uses this module. In general, we want to prohibit tabs in our markdown (using rule MD010), but there is one file where I need to use tabs in an example of the `indent` rule. Is there a way to turn off just that rule, for just that file? If not, is that a feature you would consider adding?
kerem 2026-03-03 01:22:54 +03:00
Author
Owner

@DavidAnson commented on GitHub (Aug 28, 2015):

This is basically mivok/markdownlint#16, I believe. I left a comment there a while back about how I'd probably approach this - though I'd very much prefer that both implementations agree on a strategy. I'll try to get to this soon-ish. In the meanwhile, I'm already a submitter for ESLint - if you'd like to turn off MD010 globally, I can offer to turn it back on once this feature is available AND fix any unwanted violations that crept in along the way. Does that work in the short term?

<!-- gh-comment-id:135623503 --> @DavidAnson commented on GitHub (Aug 28, 2015): This is basically mivok/markdownlint#16, I believe. I left a comment there a while back about how I'd probably approach this - though I'd very much prefer that both implementations agree on a strategy. I'll try to get to this soon-ish. In the meanwhile, I'm already a submitter for ESLint - if you'd like to turn off MD010 globally, I can offer to turn it back on once this feature is available AND fix any unwanted violations that crept in along the way. Does that work in the short term?
Author
Owner

@IanVS commented on GitHub (Aug 28, 2015):

Yep, that would do the trick. I have a temporary hack in place now that should get us through until something like this can be implemented.

As for the issue you linked to, I'm personally 👍 for:

  • Should not appear in the rendered document
  • Should optionally allow a specific rule ID to be mentioned

but 👎 for:

  • Should go on the same line where the rule violation occurred, if possible

...as it would preferably be able to handle a range of lines (or the entire file), maybe with a concept similar to /*eslint-disable*/ and /*eslint-enable*/.

<!-- gh-comment-id:135625616 --> @IanVS commented on GitHub (Aug 28, 2015): Yep, that would do the trick. I have a temporary hack in place now that should get us through until something like this can be implemented. As for the issue you linked to, I'm personally :+1: for: > - Should not appear in the rendered document > - Should optionally allow a specific rule ID to be mentioned but :-1: for: > - Should go on the same line where the rule violation occurred, if possible ...as it would preferably be able to handle a range of lines (or the entire file), maybe with a concept similar to `/*eslint-disable*/` and `/*eslint-enable*/`.
Author
Owner

@mivok commented on GitHub (Aug 28, 2015):

I'll defer to however you want to implement it (presumably html comments at this point). Sadly, I haven't had much time to work on the ruby version lately.

mivok/markdownlint#16 was initially intended to be a rule exception for a specific line rather than disabling a rule for the whole file, but the ability to disable a rule entirely makes a lot of sense.

My rationale for putting something on the same line was for a quick simple exception for a specific occurrence of a rule violation where you didn't have to specify a line number. Something like ## Hello world <!-- ignore:MD002 -->. The intent here is for it to be an option to put it on the same line and exclude any line number information rather than for it to be a requirement to do so.

<!-- gh-comment-id:135787440 --> @mivok commented on GitHub (Aug 28, 2015): I'll defer to however you want to implement it (presumably html comments at this point). Sadly, I haven't had much time to work on the ruby version lately. mivok/markdownlint#16 was initially intended to be a rule exception for a specific line rather than disabling a rule for the whole file, but the ability to disable a rule entirely makes a lot of sense. My rationale for putting something on the same line was for a quick simple exception for a specific occurrence of a rule violation where you didn't have to specify a line number. Something like `## Hello world <!-- ignore:MD002 -->`. The intent here is for it to be an option to put it on the same line and exclude any line number information rather than for it to be a requirement to do so.
Author
Owner

@IanVS commented on GitHub (Aug 28, 2015):

Hi, I completely get the reasoning behind disabling for a single line. ESLint has this concept as well. In fact, ESLint gives a lot of flexibility to configure rules:

  • Configure rules for entire file.
  • Disable/enable all linting for range of lines.
  • Disable/enable particular rule for range of lines.
  • Disable all linting for one line.
  • Disable particular rule for one line.

I don't know how feasible these are for your projects, but they certainly all come in handy for JavaScript linting.

<!-- gh-comment-id:135795273 --> @IanVS commented on GitHub (Aug 28, 2015): Hi, I completely get the reasoning behind disabling for a single line. ESLint has this concept as well. In fact, ESLint gives a lot of flexibility to [configure rules](http://eslint.org/docs/user-guide/configuring#configuring-rules): - Configure rules for entire file. - Disable/enable all linting for range of lines. - Disable/enable particular rule for range of lines. - Disable all linting for one line. - Disable particular rule for one line. I don't know how feasible these are for your projects, but they certainly all come in handy for JavaScript linting.
Author
Owner

@DavidAnson commented on GitHub (Sep 27, 2015):

See here for how to use the new functionality: https://github.com/DavidAnson/markdownlint#configuration

I believe this implementation addresses most of the scenarios @IanVS outlined with the exception of a single comment to disable a rule for a single line only. I know how I would implement that, but didn't want to complicate the initial implementation because it's just a shorthand convenience.

<!-- gh-comment-id:143506295 --> @DavidAnson commented on GitHub (Sep 27, 2015): See here for how to use the new functionality: https://github.com/DavidAnson/markdownlint#configuration I believe this implementation addresses most of the scenarios @IanVS outlined with the exception of a single comment to disable a rule for a single line only. I know how I would implement that, but didn't want to complicate the initial implementation because it's just a shorthand convenience.
Author
Owner

@DavidAnson commented on GitHub (Sep 27, 2015):

I've submitted a PR for eslint to upgrade to markdownlint 0.0.8 which contains the functionality above:
https://github.com/eslint/eslint/pull/3953

<!-- gh-comment-id:143590859 --> @DavidAnson commented on GitHub (Sep 27, 2015): I've submitted a PR for eslint to upgrade to markdownlint 0.0.8 which contains the functionality above: https://github.com/eslint/eslint/pull/3953
Author
Owner

@IanVS commented on GitHub (Sep 29, 2015):

👍 Thanks! I will test this out in the next few days.

<!-- gh-comment-id:143923512 --> @IanVS commented on GitHub (Sep 29, 2015): :+1: Thanks! I will test this out in the next few days.
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#2
No description provided.