Registry / testing / markdownlint

markdownlint

JSON →
library0.40.0jsnpmunverified

A Node.js style checker and lint tool for Markdown/CommonMark files. Current stable version is 0.40.0, released with a history of regular updates. It uses the micromark parser and honors the CommonMark specification, also supporting GFM syntax like autolinks and tables, as well as directives, footnotes, and math via micromark extensions. Unlike other Markdown linters, it provides a comprehensive library of rules and is designed for programmatic use in Node.js projects, with multiple CLI wrappers and editor integrations.

npm install markdownlint
INSTALL
IMPORT
SIG · MARKDOWNLINT
M
markdownlint
testingjavascriptv0.40.0
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

markdownlint
import markdownlint from 'markdownlint'
const markdownlint = require('markdownlint')
Package is ESM-only since v0.34.0. Use import statement.
lint
import { lint } from 'markdownlint'
Main function exported as named export. Also available as default import.
LintResults
import type { LintResults } from 'markdownlint'
import { LintResults } from 'markdownlint'
LintResults is a TypeScript type, not a runtime value. Import using 'import type'.
markdownlint.sync
import { lintSync } from 'markdownlint'
const { sync } = require('markdownlint')
Synchronous linting is available as a separate named export lintSync since v0.26.0.

Lint a Markdown file with custom configuration and log errors.

import { lint } from 'markdownlint'; import { readFileSync } from 'fs'; const options = { strings: { 'example.md': readFileSync('example.md', 'utf8'), }, config: { default: true, MD013: { line_length: 80 }, }, }; lint(options, (err, results) => { if (err) { console.error(err); return; } for (const file in results) { const errors = results[file]; errors.forEach((error) => { console.log(`${file}:${error.lineNumber}: ${error.ruleName} - ${error.ruleDescription}`); }); } });
Debug
Known issues
breakingESM-only since v0.34.0, synchronous API removed in v0.26.0
fix
Use import syntax instead of require(). Use lintSync named export for synchronous usage.
affects: >=0.34.0
deprecatedThe markdownlint.sync function is deprecated since v0.26.0
fix
Use the lintSync named export instead.
affects: >=0.26.0 <0.34.0
gotchaConfiguration files (like .markdownlint.json) are not automatically loaded when using the API programmatically
fix
Manually load and pass the config option object to the lint function.
affects: all
gotchaRule MD024 (multiple headings with same content) by default only checks siblings, not all headings
fix
Set allow_different_nesting: false in config to check all headings.
affects: all
Errors
Common errors & fixes
Cannot find module 'markdownlint'
Package not installed or used with require() in ESM-only version
fix
Install with npm: npm install markdownlint --save-dev. Use import statement instead of require().
TypeError: markdownlint.sync is not a function
Using deprecated synchronous API, or importing wrong shape
fix
Use import { lintSync } from 'markdownlint' instead of markdownlint.sync.
Invalid configuration: 'default' must be a boolean
Setting config.default to a non-boolean value like 'true' (string) or an object
fix
Set config.default as a boolean true or false, not a string. Example: default: true
Error: Cannot find module 'micromark'
markdownlint has a peer dependency on micromark that is missing
fix
Install micromark as a dependency: npm install micromark
Upgrade
Version history
0.40.0latest on npm
Audit
Dependencies
micromarkrequiredCore parsing engine for Markdown/CommonMark
Agent activity
2 hits · last 30 days
node
2
Resources
markdownlint — npm install markdownlint · libregistry