Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

@eslint/markdown

eslint756.6kMIT6.4.0TypeScript support: included

The official ESLint language plugin for Markdown

eslint, eslintplugin, markdown, lint, linter

readme

ESLint Markdown Language Plugin

npm Version Downloads Build Status

Lint JS, JSX, TypeScript, and more inside Markdown.

A JS code snippet in a Markdown editor has red squiggly underlines. A tooltip explains the problem.

Usage

Installing

Install the plugin alongside ESLint v9 or greater:

npm install --save-dev eslint @eslint/markdown

Configurations

Configuration Name Description
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 the Markdown processor on all .md files:

// eslint.config.js
import markdown from "@eslint/markdown";

export default [
    ...markdown.configs.recommended

    // your other configs here
];

Rules

Rule Name Description Recommended
fenced-code-language Require languages for fenced code blocks yes
heading-increment Enforce heading levels increment by one yes
no-duplicate-headings Disallow duplicate headings in the same document no
no-empty-links Disallow empty links yes
no-html Disallow HTML tags no
no-invalid-label-refs Disallow invalid label references yes
no-missing-label-refs Disallow missing label references yes

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:

// eslint.config.js
import markdown from "@eslint/markdown";

export default [
    {
        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

Language Name Description
commonmark Parse using CommonMark Markdown format
gfm Parse using GitHub-Flavored Markdown format

In order to individually configure a language in your eslint.config.js file, import @eslint/markdown and configure a language:

// eslint.config.js
import markdown from "@eslint/markdown";

export default [
    {
        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.

Option Value Description
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.
// eslint.config.js
import markdown from "@eslint/markdown";

export default [
    {
        files: ["**/*.md"],
        plugins: {
            markdown
        },
        language: "markdown/gfm",
        languageOptions: {
            frontmatter: "yaml", // Or pass `"toml"` to enable TOML front matter parsing.
        },
        rules: {
            "markdown/no-html": "error"
        }
    }
];

Processors

Processor Name Description
markdown Extract fenced code blocks from the Markdown code so they can be linted separately.

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.

Sponsors

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.

Diamond Sponsors

AG Grid

Platinum Sponsors

Automattic Airbnb

Gold Sponsors

Qlty Software trunk.io Shopify

Silver Sponsors

Vite Liftoff American Express StackBlitz

Bronze Sponsors

Cybozu Anagram Solver Icons8 Discord GitBook Neko Nx Mercedes-Benz Group HeroCoders LambdaTest

Technology Sponsors

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.

Netlify Algolia 1Password

changelog

Changelog

6.4.0 (2025-04-17)

Features

Bug Fixes

  • enhance fenced code language rule to support tilde as a delimiter (#344) (852645e)
  • replace IMarkdownSourceCode with MarkdownSourceCode (#336) (ec2846b)

6.3.0 (2025-03-04)

Features

  • allow specifying filename in block meta (#318) (7075f00)

6.2.2 (2025-01-17)

Bug Fixes

6.2.1 (2024-10-16)

Bug Fixes

  • no-missing-label-refs should not crash on undefined labels (#290) (ac1bc1c)

6.2.0 (2024-10-03)

Features

6.1.1 (2024-09-26)

Bug Fixes

6.1.0 (2024-09-02)

Features

Bug Fixes

  • correct exports field in package.json (#279) (8e40d30)

6.0.0 (2024-08-21)

⚠ BREAKING CHANGES

  • Rename to @eslint/markdown (#265)
  • Convert to ESM (#259)

Features

5.1.0 (2024-07-05)

Features

5.0.0 (2024-05-01)

⚠ BREAKING CHANGES

  • map known code block languages to respective file extensions (#246)

Features

  • map known code block languages to respective file extensions (#246) (096cff4)

Bug Fixes

  • check upper bounds of message line numbers for code blocks (#247) (00adccb)

Chores

  • run tests in Node.js 22, with ESLint 9 (#250) (085e6d5)
  • switch to eslint v9, eslint-config-eslint v10 (#251) (a76cdf5)

4.0.1 (2024-03-06)

Chores

  • update changelog with note that v4.0.0 was not published to npm (#241) (e80139d)

4.0.0 (2024-03-01)

⚠️ This release was not published to npm due to technical problems.

⚠ BREAKING CHANGES

  • drop eslint < 8 & Node.js < 18 (#238)
  • Switch to flat config (#232)

Features

Documentation

  • fix expected errors in react example (#237) (a758163)

Chores

  • add .vscode to .gitignore (#236) (cbb8e3a)
  • bump setup-node and checkout actions to v4 in release workflow (#239) (3fd99ad)
  • remove unused @eslint/eslintrc in test examples (#234) (4e2e160)
  • run tests in Node.js 21 (#225) (4d9f36f)
  • standardize npm script names (#223) (6bdff60)
  • use latest typescript-eslint in examples (#235) (313959b)

3.0.1 (2023-07-15)

Chores

v3.0.0 - July 16, 2022

  • 558ae3c chore: add node v18 (#205) (Amaresh S M)
  • 071fa66 feat!: drop node v8 and v10 (#203) (Amaresh S M)
  • f186730 ci: update github actions (#207) (Deepshika S)
  • 6570c82 ci: Work around npm behavior changes to fix CI on main (#206) (Brandon Mills)
  • 87c2b53 docs: update badges (#202) (Milos Djermanovic)
  • 2fd5b89 chore: add tests for ESLint 8 (#195) (Michaël De Boey)
  • 8db0978 chore: Check for package.json in examples (#200) (Brandon Mills)
  • b695396 test: test with ESLint instead of CLIEngine when available (#198) (Michaël De Boey)
  • e1ddcc5 ci: use node v16 (#199) (Nitin Kumar)
  • 8f590fc chore: update devDependencies (#197) (Michaël De Boey)
  • 3667566 chore: test all supported ESLint versions (#196) (Michaël De Boey)
  • ecae4fe Chore: ignore pnpm-lock.yaml (#193) (Nitin Kumar)
  • ffdb245 Chore: use actions/setup-node@v2 in CI (#192) (Nitin Kumar)

v2.2.1 - September 11, 2021

  • 3a40160 Fix: message.line could be undefined (#191) (JounQin)

v2.2.0 - May 26, 2021

  • 32203f6 Update: Replace Markdown parser (fixes #125, fixes #186) (#188) (Brandon Mills)

v2.1.0 - April 25, 2021

  • f1e153b Update: Upgrade remark-parse to v7 (fixes #77, fixes #78) (#175) (Brandon Mills)

v2.0.1 - April 5, 2021

  • d23d5f7 Fix: use blocksCache instead of single blocks instance (fixes #181) (#183) (JounQin)
  • a09a645 Chore: add yarn.lock and package-lock.json into .gitignore (#184) (JounQin)
  • 1280ac1 Docs: improve jsdoc, better for typings (#182) (JounQin)
  • 79be776 Fix: More reliable comment attachment (fixes #76) (#177) (Brandon Mills)

v2.0.0 - February 14, 2021

  • 53dc0e5 Docs: Remove prerelease README notes (#173) (Brandon Mills)
  • 140adf4 2.0.0-rc.2 (ESLint Jenkins)
  • 15d7aa6 Build: changelog update for 2.0.0-rc.2 (ESLint Jenkins)
  • f6a3fad Fix: overrides pattern for virtual filenames in recommended config (#169) (Milos Djermanovic)
  • 390d508 2.0.0-rc.1 (ESLint Jenkins)
  • e05d6eb Build: changelog update for 2.0.0-rc.1 (ESLint Jenkins)
  • 1dd7089 Fix: npm prepare script on Windows (refs #166) (#168) (Brandon Mills)
  • 23ac2b9 Fix: Ignore words in info string after syntax (fixes #166) (#167) (Brandon Mills)
  • 8f729d3 Chore: Switch to main for primary branch (fixes #161) (#165) (Brandon Mills)
  • d30c50f Chore: Automatically install example dependencies (#164) (Brandon Mills)
  • 2749b4d 2.0.0-rc.0 (ESLint Jenkins)
  • 922a00e Build: changelog update for 2.0.0-rc.0 (ESLint Jenkins)
  • d94c22f Build: Install example test dependencies in Jenkins (#160) (Brandon Mills)
  • 7f26cb9 Docs: Reference recommended config disabled rules (#159) (Brandon Mills)
  • bf7648f Docs: Add TypeScript example (#155) (Brandon Mills)
  • d80be9e New: Add rules to recommended config (#157) (Nikolay Stoynov)
  • fc4d7aa Chore: run CI in Node 14.x (#158) (Kai Cataldo)
  • f2d4923 Docs: Add React example (#152) (Brandon Mills)
  • eb66833 New: Add recommended config (fixes #151) (#153) (Brandon Mills)
  • 0311640 Fix: Don't require message end locations (fixes #112) (#154) (Brandon Mills)
  • 2bc9352 2.0.0-alpha.0 (ESLint Jenkins)
  • c0ba401 Build: changelog update for 2.0.0-alpha.0 (ESLint Jenkins)
  • 51e48c6 Docs: Revamp documentation for v2 (#149) (Brandon Mills)
  • b221391 Docs: Dogfood plugin by linting readme (#145) (Brandon Mills)
  • 7423610 Docs: Explain use of --ext option in ESLint v7 (#146) (Brandon Mills)
  • 0d4dbe8 Breaking: Implement new processor API (fixes #138) (#144) (Brandon Mills)
  • 7eeafb8 Chore: Update ESLint config and plugins (#143) (Brandon Mills)
  • f483343 Breaking: Require ESLint v6 (#142) (Brandon Mills)
  • 9aa1fdc Chore: Use ES2018 object spread syntax (#141) (Brandon Mills)
  • f584cc6 Build: Remove Travis (#140) (Brandon Mills)
  • 35f9a11 Breaking: Drop support for Node.js v6 (refs #138) (#137) (Brandon Mills)
  • 6f02ef5 Chore: Add npm version and build status badges (#139) (Brandon Mills)

v2.0.0-rc.2 - January 30, 2021

  • f6a3fad Fix: overrides pattern for virtual filenames in recommended config (#169) (Milos Djermanovic)

v2.0.0-rc.1 - December 20, 2020

  • 1dd7089 Fix: npm prepare script on Windows (refs #166) (#168) (Brandon Mills)
  • 23ac2b9 Fix: Ignore words in info string after syntax (fixes #166) (#167) (Brandon Mills)
  • 8f729d3 Chore: Switch to main for primary branch (fixes #161) (#165) (Brandon Mills)
  • d30c50f Chore: Automatically install example dependencies (#164) (Brandon Mills)

v2.0.0-rc.0 - August 19, 2020

  • d94c22f Build: Install example test dependencies in Jenkins (#160) (Brandon Mills)
  • 7f26cb9 Docs: Reference recommended config disabled rules (#159) (Brandon Mills)
  • bf7648f Docs: Add TypeScript example (#155) (Brandon Mills)
  • d80be9e New: Add rules to recommended config (#157) (Nikolay Stoynov)
  • fc4d7aa Chore: run CI in Node 14.x (#158) (Kai Cataldo)
  • f2d4923 Docs: Add React example (#152) (Brandon Mills)
  • eb66833 New: Add recommended config (fixes #151) (#153) (Brandon Mills)
  • 0311640 Fix: Don't require message end locations (fixes #112) (#154) (Brandon Mills)

v2.0.0-alpha.0 - April 12, 2020

  • 51e48c6 Docs: Revamp documentation for v2 (#149) (Brandon Mills)
  • b221391 Docs: Dogfood plugin by linting readme (#145) (Brandon Mills)
  • 7423610 Docs: Explain use of --ext option in ESLint v7 (#146) (Brandon Mills)
  • 0d4dbe8 Breaking: Implement new processor API (fixes #138) (#144) (Brandon Mills)
  • 7eeafb8 Chore: Update ESLint config and plugins (#143) (Brandon Mills)
  • f483343 Breaking: Require ESLint v6 (#142) (Brandon Mills)
  • 9aa1fdc Chore: Use ES2018 object spread syntax (#141) (Brandon Mills)
  • f584cc6 Build: Remove Travis (#140) (Brandon Mills)
  • 35f9a11 Breaking: Drop support for Node.js v6 (refs #138) (#137) (Brandon Mills)
  • 6f02ef5 Chore: Add npm version and build status badges (#139) (Brandon Mills)

v1.0.2 - February 24, 2020

  • 52e0984 Upgrade: Update devDeps and change istanbul -> nyc (#130) (Brett Zamir)
  • d52988f Chore: Remove call to lint absent Makefile.js (#129) (Brett Zamir)
  • 5640ea6 Fix: Apply base indent to multiple line breaks (fixes #127) (#128) (Brett Zamir)

v1.0.1 - October 21, 2019

  • fb0b5a3 Fix: Indent multiline fixes (fixes #120) (#124) (Brandon Mills)
  • 07c9017 Chore: Use GitHub Actions (#123) (Brandon Mills)
  • b5bf014 Chore: Add Node 12 to Travis (#122) (Brandon Mills)
  • dc90961 Fix: Support autofix at the very start of blocks (fixes #117) (#119) (Simon Lydell)
  • 2de2490 Docs: Syntax highlight Markdown (#116) (Brett Zamir)
  • fdacf0c Chore: Upgrade to eslint-config-eslint@5.0.1 (#110) (Brandon Mills)

v1.0.0 - January 2, 2019

  • 2a8482e Fix: overrides general docs and Atom linter-eslint tips (fixes #109) (#111) (Brett Zamir)

v1.0.0-rc.1 - November 5, 2018

  • a2f4492 Fix: Allowing eslint-plugin-prettier to work (fixes #101) (#107) (simlu)

v1.0.0-rc.0 - October 27, 2018

  • 8fe9a0e New: Enable autofix with --fix (fixes #58) (#97) (Bohdan Khodakivskyi)
  • a5d0cce Fix: Ignore anything after space in code fence's language (fixes #98) (#99) (Francisco Ryan Tolmasky I)
  • 6fd340d Upgrade: eslint-release@1.0.0 (#100) (Teddy Katz)
  • dff8e9c Fix: Emit correct endLine numbers (#88) (Paul Murray)
  • 83f00d0 Docs: Suggest disabling strict in .md files (fixes #94) (#95) (Brandon Mills)
  • 3b4ff95 Build: Test against Node v10 (#96) (Brandon Mills)
  • 6777977 Breaking: required node version 6+ (#89) (薛定谔的猫)
  • 5582fce Docs: Updating CLA link (#93) (Pablo Nevares)
  • 24070e6 Build: Upgrade to eslint-release@0.11.1 (#92) (Brandon Mills)
  • 6cfd1f0 Docs: Add unicode-bom to list of unsatisfiable rules (#91) (Brandon Mills)

v1.0.0-beta.8 - April 8, 2018

  • a1544c2 Chore: Add .npmrc to disable creating package-lock.json (#90) (Brandon Mills)
  • 47ad3f9 Chore: Replace global comment integration test with unit test (refs #81) (#85) (Brandon Mills)
  • e34acc6 Fix: Add unicode-bom to unsatisfiable rules (refs #75) (#84) (Brandon Mills)
  • 7c19f8b Fix: Support globals (fixes #79) (#81) (Anders D. Johnson)

v1.0.0-beta.7 - July 2, 2017

  • f8ba18a New: Custom eslint-skip HTML comment skips blocks (fixes #69) (#73) (Brandon Mills)
  • 249904f Chore: Add test for code fences without blank lines (#72) (Brandon Mills)
  • 3abc569 Chore: Un-disable strict and eol-last in repository (#71) (Brandon Mills)
  • 132ea5b Chore: Add test ensuring config comments do not fall through (#70) (Brandon Mills)

v1.0.0-beta.6 - April 29, 2017

  • c5e9d67 Build: Explicitly specify package.json files (#67) (Brandon Mills)

v1.0.0-beta.5 - April 29, 2017

  • 7bd0f6e Build: Install eslint-release (#66) (Brandon Mills)
  • 48122eb Build: Dogfood plugin without npm link (#65) (Brandon Mills)
  • cc7deea Chore: Increase code coverage (#64) (Brandon Mills)
  • 29f2f05 Build: Use eslint-release (#63) (Brandon Mills)
  • d2f2962 Upgrade: remark (#62) (Titus)