Skip to content

NoiseFan/eslint-plugin-md-style

Repository files navigation

eslint-plugin-md-style

npm version npm downloads codecov

ESLint plugin for enforcing style rules in Markdown-based documentation.

Overview

eslint-plugin-md-style provides Markdown-specific style rules and ready-to-use flat configs for **/*.md files.

It currently ships:

  • A recommended config for typical documentation linting
  • An all config that enables every rule in this plugin
  • Markdown language registration built on top of @eslint/markdown

Quick Start

Version Requirements

  • eslint: ^9.30.0 or ^10.0.0
  • @antfu/eslint-config: ^7.5.0 when used

This plugin is designed for ESLint flat config. If you use @antfu/eslint-config, make sure its version satisfies the requirement above.

Install the required packages:

pnpm add -D eslint @eslint/markdown eslint-plugin-md-style

Then enable the recommended config in your ESLint flat config:

import mdStyle from 'eslint-plugin-md-style'

export default [
  mdStyle.configs.recommended,
]

If you want full enforcement, replace mdStyle.configs.recommended with mdStyle.configs.all.

Usage

Manual Flat Config Usage

Use the built-in preset directly:

import mdStyle from 'eslint-plugin-md-style'

export default [
  mdStyle.configs.recommended,
]

You can also enable the plugin manually and choose rules one by one:

import mdStyle from 'eslint-plugin-md-style'

export default [
  {
    files: ['**/*.md'],
    plugins: {
      'md-style': mdStyle,
    },
    language: 'md-style/gfm',
    rules: {
      'md-style/space-between-inline-element': 'error',
      'md-style/valid-heading-anchor': 'error',
    },
  },
]
Usage with @antfu/eslint-config
import antfu from '@antfu/eslint-config'
import mdStyle from 'eslint-plugin-md-style'

export default antfu(
  {
    formatters: true,
    markdown: true,
  },
  mdStyle.configs.recommended,
)

For partial adoption, start from recommended and override individual rules:

import antfu from '@antfu/eslint-config'
import mdStyle from 'eslint-plugin-md-style'

export default antfu(
  {
    formatters: true,
    markdown: true,
  },
  mdStyle.configs.recommended,
  {
    files: ['**/*.md'],
    rules: {
      'md-style/valid-heading-anchor': 'off',
    },
  },
)

Rules

Rule Included in recommended Autofix
md-style/space-between-inline-element 🔧
md-style/valid-heading-anchor 🔧

Why @eslint/markdown Is Required

This plugin builds on top of @eslint/markdown rather than replacing it.

@eslint/markdown provides the Markdown processor and language support. This plugin re-exports those capabilities through its own plugin entry and adds documentation style rules on top, including the md-style/gfm language used by the bundled configs.

References

License

MIT License © 2025-PRESENT Noise Fan

About

ESLint plugin for enforcing style rules in Markdown-based documentation

Topics

Resources

License

Stars

Watchers

Forks

Sponsor this project

Packages

 
 
 

Contributors