ESLint Markdown Language Plugin

Lint Markdown with ESLint, as well JS, JSX, TypeScript, and more inside Markdown.

Usage
Installing
Install the plugin alongside ESLint v9.15.0 or greater.
For Node.js and compatible runtimes:
npm install @eslint/markdown -D
yarn add @eslint/markdown -D
pnpm install @eslint/markdown -D
bun add @eslint/markdown -D
For Deno:
deno add jsr:@eslint/markdown
Configurations
recommended | Lints all .md files with the recommended rules and assumes CommonMark format. |
processor | Enables extracting code blocks from all .md files so code blocks can be individually linted. |
In your eslint.config.js file, import @eslint/markdown and include the recommended config to enable Markdown parsing and linting:
import { defineConfig } from "eslint/config";
import markdown from "@eslint/markdown";
export default defineConfig([
{
files: ["**/*.md"],
plugins: {
markdown,
},
extends: ["markdown/recommended"],
},
]);
You can also modify the recommended config by using extends:
import { defineConfig } from "eslint/config";
import markdown from "@eslint/markdown";
export default defineConfig([
{
plugins: {
markdown,
},
extends: ["markdown/recommended"],
rules: {
"markdown/no-html": "error",
},
},
]);
Rules
Note: This plugin does not provide formatting rules. We recommend using a source code formatter such as Prettier for that purpose.
In order to individually configure a rule in your eslint.config.js file, import @eslint/markdown and configure each rule with a prefix:
import { defineConfig } from "eslint/config";
import markdown from "@eslint/markdown";
export default defineConfig([
{
files: ["**/*.md"],
plugins: {
markdown,
},
language: "markdown/commonmark",
rules: {
"markdown/no-html": "error",
},
},
]);
You can individually disable rules in Markdown using HTML comments, such as:
<!-- eslint-disable-next-line markdown/no-html -- I want to allow HTML here -->
<custom-element>Hello world!</custom-element>
<!-- eslint-disable markdown/no-html -- here too -->
<another-element>Goodbye world!</another-element>
<!-- eslint-enable markdown/no-html -- safe to re-enable now -->
[Object] <!-- eslint-disable-line markdown/no-missing-label-refs -- not meant to be a link ref -->
Languages
In order to individually configure a language in your eslint.config.js file, import @eslint/markdown and configure a language:
import { defineConfig } from "eslint/config";
import markdown from "@eslint/markdown";
export default defineConfig([
{
files: ["**/*.md"],
plugins: {
markdown,
},
language: "markdown/gfm",
rules: {
"markdown/no-html": "error",
},
},
]);
Language Options
Enabling Front Matter in both commonmark and gfm
By default, Markdown parsers do not support front matter. To enable front matter in both commonmark and gfm, you can use the frontmatter option in languageOptions.
@eslint/markdown internally uses micromark-extension-frontmatter and mdast-util-frontmatter to parse front matter.
false | Disables front matter parsing in Markdown files. (Default) |
"yaml" | Enables YAML front matter parsing in Markdown files. |
"toml" | Enables TOML front matter parsing in Markdown files. |
"json" | Enables JSON front matter parsing in Markdown files. |
import { defineConfig } from "eslint/config";
import markdown from "@eslint/markdown";
export default defineConfig([
{
files: ["**/*.md"],
plugins: {
markdown,
},
language: "markdown/gfm",
languageOptions: {
frontmatter: "yaml",
},
rules: {
"markdown/no-html": "error",
},
},
]);
Processors
markdown | Extract fenced code blocks from the Markdown code so they can be linted separately. |
Migration from eslint-plugin-markdown
See Migration.
Editor Integrations
VSCode
vscode-eslint has built-in support for the Markdown processor.
File Name Details
This processor will use file names from blocks if a filename meta is present.
For example, the following block will result in a parsed file name of src/index.js:
```js filename="src/index.js"
export const value = "Hello, world!";
```
This can be useful for user configurations that include linting overrides for specific file paths. In this example, you could then target the specific code block in your configuration using "file-name.md/*src/index.js".
Contributing
$ git clone https://github.com/eslint/markdown.git
$ cd markdown
$ npm install
$ npm test
This project follows the ESLint contribution guidelines.
The following companies, organizations, and individuals support ESLint's ongoing maintenance and development. Become a Sponsor
to get your logo on our READMEs and website.




Technology sponsors allow us to use their products and services for free as part of a contribution to the open source ecosystem and our work.
