[GH-ISSUE #171] MD031 should ignore prettier-ignore comment #1996

Closed
opened 2026-03-07 20:03:31 +03:00 by kerem · 5 comments
Owner

Originally created by @plehnen on GitHub (Mar 13, 2019).
Original GitHub issue: https://github.com/DavidAnson/markdownlint/issues/171

Putting <!-- prettier-ignore --> one line above some code block will cause the error MD031 - Fenced code blocks should be surrounded by blank lines.

It should ignore html comments when checking for blank lines.

The prettier-ignore is needed, because otherwise prettier would format the code to one line, removing my intended formatting.

Originally created by @plehnen on GitHub (Mar 13, 2019). Original GitHub issue: https://github.com/DavidAnson/markdownlint/issues/171 Putting `<!-- prettier-ignore -->` one line above some code block will cause the error **MD031 - Fenced code blocks should be surrounded by blank lines**. It should ignore html comments when checking for blank lines. The prettier-ignore is needed, because otherwise prettier would format the code to one line, removing my intended formatting.
kerem 2026-03-07 20:03:31 +03:00
Author
Owner

@DavidAnson commented on GitHub (Mar 13, 2019):

Can you show an example, please? This sounds kind of like a workaround for a bug in prettier. I may still implement this, but I’d like to see the scenario first. Thanks!

<!-- gh-comment-id:472497737 --> @DavidAnson commented on GitHub (Mar 13, 2019): Can you show an example, please? This sounds kind of like a workaround for a bug in prettier. I may still implement this, but I’d like to see the scenario first. Thanks!
Author
Owner

@plehnen commented on GitHub (Mar 13, 2019):

Sure! This is how the part of the file looks like:

> Settings > Editor > Live Templates > Vue

- vcomputed

<!-- prettier-ignore -->
```vue
computed: {
  $name$() {
    return this.$data$ $END$;
  },
},
```

Removing the prettier-ignore will format the code in a way which is not desired.
Leaving it there will be warned by markdownlint.
Adding a blank line between the prettier-ignore and the block code will automatically be removed by prettier.

<!-- gh-comment-id:472502474 --> @plehnen commented on GitHub (Mar 13, 2019): Sure! This is how the part of the file looks like: <pre> > Settings > Editor > Live Templates > Vue - vcomputed &lt;!-- prettier-ignore --&gt; ```vue computed: { $name$() { return this.$data$ $END$; }, }, ``` </pre> Removing the prettier-ignore will format the code in a way which is not desired. Leaving it there will be warned by markdownlint. Adding a blank line between the prettier-ignore and the block code will automatically be removed by prettier.
Author
Owner

@DavidAnson commented on GitHub (Mar 13, 2019):

Makes sense. Any idea why prettier thinks it can reformat your code fence? It probably should never do that because it’s almost certain to change the way the content renders.

<!-- gh-comment-id:472540662 --> @DavidAnson commented on GitHub (Mar 13, 2019): Makes sense. Any idea why prettier thinks it can reformat your code fence? It probably should never do that because it’s almost certain to change the way the content renders.
Author
Owner

@plehnen commented on GitHub (Mar 13, 2019):

No idea, sorry. I am relatively new to the world of linters ;)
But I feel that a html comment could be placed anywhere and should just be ignored by the linter.
Especially because the comment used as a ignore rule has to be directly attached to the code it belongs to.

<!-- gh-comment-id:472564241 --> @plehnen commented on GitHub (Mar 13, 2019): No idea, sorry. I am relatively new to the world of linters ;) But I feel that a html comment could be placed anywhere and should just be ignored by the linter. Especially because the comment used as a ignore rule has to be directly attached to the code it belongs to.
Author
Owner

@DavidAnson commented on GitHub (Mar 14, 2019):

FYI: I opened https://github.com/prettier/prettier/issues/5971 to track the unexpected reformatting in the Prettier project. I'll use this issue to track the above suggestion for markdownlint.

<!-- gh-comment-id:472703048 --> @DavidAnson commented on GitHub (Mar 14, 2019): FYI: I opened https://github.com/prettier/prettier/issues/5971 to track the unexpected reformatting in the `Prettier` project. I'll use this issue to track the above suggestion for `markdownlint`.
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#1996
No description provided.