{"id":25923,"library":"markdownlint","title":"markdownlint","description":"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.","status":"active","version":"0.40.0","language":"javascript","source_language":"en","source_url":"https://github.com/DavidAnson/markdownlint","tags":["javascript","markdown","lint","md","CommonMark","markdownlint","typescript"],"install":[{"cmd":"npm install markdownlint","lang":"bash","label":"npm"},{"cmd":"yarn add markdownlint","lang":"bash","label":"yarn"},{"cmd":"pnpm add markdownlint","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Core parsing engine for Markdown/CommonMark","package":"micromark","optional":false}],"imports":[{"note":"Package is ESM-only since v0.34.0. Use import statement.","wrong":"const markdownlint = require('markdownlint')","symbol":"markdownlint","correct":"import markdownlint from 'markdownlint'"},{"note":"Main function exported as named export. Also available as default import.","wrong":null,"symbol":"lint","correct":"import { lint } from 'markdownlint'"},{"note":"LintResults is a TypeScript type, not a runtime value. Import using 'import type'.","wrong":"import { LintResults } from 'markdownlint'","symbol":"LintResults","correct":"import type { LintResults } from 'markdownlint'"},{"note":"Synchronous linting is available as a separate named export lintSync since v0.26.0.","wrong":"const { sync } = require('markdownlint')","symbol":"markdownlint.sync","correct":"import { lintSync } from 'markdownlint'"}],"quickstart":{"code":"import { lint } from 'markdownlint';\nimport { readFileSync } from 'fs';\n\nconst options = {\n  strings: {\n    'example.md': readFileSync('example.md', 'utf8'),\n  },\n  config: {\n    default: true,\n    MD013: { line_length: 80 },\n  },\n};\n\nlint(options, (err, results) => {\n  if (err) {\n    console.error(err);\n    return;\n  }\n  for (const file in results) {\n    const errors = results[file];\n    errors.forEach((error) => {\n      console.log(`${file}:${error.lineNumber}: ${error.ruleName} - ${error.ruleDescription}`);\n    });\n  }\n});","lang":"typescript","description":"Lint a Markdown file with custom configuration and log errors."},"warnings":[{"fix":"Use import syntax instead of require(). Use lintSync named export for synchronous usage.","message":"ESM-only since v0.34.0, synchronous API removed in v0.26.0","severity":"breaking","affected_versions":">=0.34.0"},{"fix":"Use the lintSync named export instead.","message":"The markdownlint.sync function is deprecated since v0.26.0","severity":"deprecated","affected_versions":">=0.26.0 <0.34.0"},{"fix":"Manually load and pass the config option object to the lint function.","message":"Configuration files (like .markdownlint.json) are not automatically loaded when using the API programmatically","severity":"gotcha","affected_versions":"all"},{"fix":"Set allow_different_nesting: false in config to check all headings.","message":"Rule MD024 (multiple headings with same content) by default only checks siblings, not all headings","severity":"gotcha","affected_versions":"all"}],"env_vars":null,"last_verified":"2026-05-01T00:00:00.000Z","next_check":"2026-07-30T00:00:00.000Z","problems":[{"fix":"Install with npm: npm install markdownlint --save-dev. Use import statement instead of require().","cause":"Package not installed or used with require() in ESM-only version","error":"Cannot find module 'markdownlint'"},{"fix":"Use import { lintSync } from 'markdownlint' instead of markdownlint.sync.","cause":"Using deprecated synchronous API, or importing wrong shape","error":"TypeError: markdownlint.sync is not a function"},{"fix":"Set config.default as a boolean true or false, not a string. Example: default: true","cause":"Setting config.default to a non-boolean value like 'true' (string) or an object","error":"Invalid configuration: 'default' must be a boolean"},{"fix":"Install micromark as a dependency: npm install micromark","cause":"markdownlint has a peer dependency on micromark that is missing","error":"Error: Cannot find module 'micromark'"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}