eslint-plugin-markdownlint

May 25, 2026 · View on GitHub

ESLint plugin that runs markdownlint rules on Markdown files.

npm version License: MIT

Install

npm install eslint-plugin-markdownlint --save-dev

Usage

Flat config (ESLint ≥9)

// eslint.config.js
import markdownlint from "eslint-plugin-markdownlint";
import markdownlintParser from "eslint-plugin-markdownlint/parser.js";

export default [
  {
    files: ["**/*.md"],
    plugins: { markdownlint },
    languageOptions: { parser: markdownlintParser },
    rules: {
      ...markdownlint.configs.recommended.rules,
    },
  },
];

Legacy .eslintrc

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

Configuring rules

All rules accept an options object matching the corresponding markdownlint rule parameters. For example:

rules: {
  "markdownlint/md013": ["error", { line_length: 100, code_blocks: false }],
  "markdownlint/md033": ["error", { allowed_elements: ["br", "details"] }],
  "markdownlint/md025": "off",
}

See markdownlint rules documentation for the full list of available options per rule.

Config file integration

The plugin automatically reads the nearest .markdownlint.json or .markdownlint.jsonc file, walking up from the linted file's directory. This is the same file the vscode-markdownlint extension reads, so you can share configuration between the editor and ESLint without duplication.

Rule options in your ESLint config always take precedence over the config file.

Custom config file location

If your config file is in a non-standard location, point to it via ESLint settings:

// eslint.config.js
export default [
  {
    files: ["**/*.md"],
    plugins: { markdownlint },
    languageOptions: { parser: markdownlintParser },
    settings: {
      markdownlint: { configFile: ".config/.markdownlint.json" },
    },
    rules: markdownlint.configs.recommended.rules,
  },
];

The path is resolved relative to the current working directory.

TypeScript

The package ships with type definitions. Rule option types are exported for use in typed ESLint configs:

import type { MD013Options, MD033Options } from "eslint-plugin-markdownlint";

The RuleOptionsMap type maps each rule name to its options interface, which is useful with typed flat config helpers.

Supported rules

All built-in markdownlint rules are supported (MD001–MD060, excluding the deprecated MD002 and MD006):

RuleDescription
MD001Heading levels should only increment by one level at a time
MD003Heading style
MD004Unordered list style
MD005Inconsistent indentation for list items at the same level
MD007Unordered list indentation
MD009Trailing spaces
MD010Hard tabs
MD011Reversed link syntax
MD012Multiple consecutive blank lines
MD013Line length
MD014Dollar signs used before commands without showing output
MD018No space after hash on atx style heading
MD019Multiple spaces after hash on atx style heading
MD020No space inside hashes on closed atx style heading
MD021Multiple spaces inside hashes on closed atx style heading
MD022Headings should be surrounded by blank lines
MD023Headings must start at the beginning of the line
MD024Multiple headings with the same content
MD025Multiple top-level headings in the same document
MD026Trailing punctuation in heading
MD027Multiple spaces after blockquote symbol
MD028Blank line inside blockquote
MD029Ordered list item prefix
MD030Spaces after list markers
MD031Fenced code blocks should be surrounded by blank lines
MD032Lists should be surrounded by blank lines
MD033Inline HTML
MD034Bare URL used
MD035Horizontal rule style
MD036Emphasis used instead of a heading
MD037Spaces inside emphasis markers
MD038Spaces inside code span elements
MD039Spaces inside link text
MD040Fenced code blocks should have a language specified
MD041First line in a file should be a top-level heading
MD042No empty links
MD043Required heading structure
MD044Proper names should have the correct capitalization
MD045Images should have alternate text (alt text)
MD046Code block style
MD047Files should end with a single newline character
MD048Code fence style
MD049Emphasis style
MD050Strong style
MD051Link fragments should be valid
MD052Reference links and images should use a label that is defined
MD053Link and image reference definitions should be needed
MD054Link and image style
MD055Table pipe style
MD056Table column count
MD058Tables should be surrounded by blank lines
MD059Link text should be descriptive
MD060Table column style

Markdownlint documentation

For full rule documentation refer to DavidAnson/markdownlint.