'How do I override markdown rules in Prettier?

I use the Prettier extension for VSCode. I've managed to set up a base project that extends ESLint such that I can format my JavaScript syntax automatically on save, following the standard rules.

Is there a way to do the same for markdown? I'd like to leverage markdownlint rules or similar since Prettier forces numbered lists as:

<!-- Prettier rules -->
1. This is
1. A numbered
1. List

But I prefer manual numbering like so:

<!-- My rules -->
1. This is
2. A manual 
3. List


Solution 1:[1]

Prettier does not enforce numbered lists as:

1. first
1. second
1. third

See this on Prettier's playground: link

It will detect if your 2nd item is also 1. and format the list like that, otherwise, it will format with incrementing numbers.

There's no way to override Prettier's rules, can only change the options passed, but for markdown only the --prose-wrap option is available. You are free to run Prettier and then run markdownlint later to adjust to your preferences, if you so desire, just like one would do with ESLint.

Solution 2:[2]

Not exactly what you asked for, but you can desactivate Prettier for MarkDown files by creating a file named .prettierignore in the project root, in which you write *.md.

See Prettier documentation for details.

Solution 3:[3]

You can use eslint-plugin-markdownlint to lint your markdown files.

With settings to override rules for .md files it will take precedence over prettier:

// .eslintrc
{
  "overrides": [{
    "files": ["*.md"],
    "parser": "eslint-plugin-markdownlint/parser",
    "extends": ["plugin:markdownlint/recommended"]
  }]
}

Note: I'm author of this plugin, but this uses markdownlint library to lint files.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Lucas
Solution 2 xiaoju
Solution 3 Paweł BB Drozd