ESLint plugin for enforcing style rules in Markdown-based documentation.
eslint-plugin-md-style provides Markdown-specific style rules and ready-to-use flat configs for **/*.md files.
It currently ships:
- A
recommendedconfig for typical documentation linting - An
allconfig that enables every rule in this plugin - Markdown language registration built on top of
@eslint/markdown
eslint:^9.30.0or^10.0.0@antfu/eslint-config:^7.5.0when 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-styleThen 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.
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',
},
},
)| Rule | Included in recommended |
Autofix |
|---|---|---|
md-style/space-between-inline-element |
✅ | 🔧 |
md-style/valid-heading-anchor |
✅ | 🔧 |
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.