Inconsistent markdown is a common source of friction in collaborative projects. Authors mix emphasis markers (Documentation Index
Fetch the complete documentation index at: https://mintlify.com/remarkjs/remark/llms.txt
Use this file to discover all available pages before exploring further.
* vs _), ordered list styles (. vs )), and may omit final newlines — issues that are invisible when rendered but create noisy diffs and make automated processing less predictable. remark-lint is a remark plugin that reports these inconsistencies as structured warnings attached to the virtual file, letting you enforce a consistent style programmatically or from the command line.
How remark-lint works
remark-lint is not a standalone tool — it is a collection of individual rule plugins that plug into the remark pipeline. Each rule checks one aspect of markdown style and attaches warning messages to the vfile when it finds a violation. After processing, you pass the file throughvfile-reporter to produce human-readable output.
Rather than installing individual rules one by one, it is practical to start with a preset: a curated bundle of rules with opinionated defaults.
Lint presets
Three official presets cover the most common needs:| Preset | Purpose |
|---|---|
remark-preset-lint-consistent | Enforces internal consistency — e.g., the emphasis marker you use first becomes the required marker for the rest of the document |
remark-preset-lint-recommended | A small set of rules representing broadly agreed best practices |
remark-preset-lint-markdown-style-guide | A thorough style guide with opinions about every aspect of markdown formatting |
Linting programmatically
Install the presets and the reporter:) list marker should be ., the * emphasis marker should be _ (to match the _ used earlier in the same document — remark-preset-lint-consistent records where the first style was established and reports it as a [cause]), and the file is missing a trailing newline.
Linting files with remark-cli
For checking markdown files in a project,remark-cli is the right tool. It accepts glob patterns, loads configuration from your project, and exits with a non-zero code when issues are found — making it suitable for CI pipelines.
Rather than passing plugins as CLI flags every time, add a
remarkConfig field to your package.json to keep the configuration in one place:{
"remarkConfig": {
"plugins": [
"remark-preset-lint-consistent",
"remark-preset-lint-recommended"
]
}
}
Configuration files
For larger projects, or when you need comments in your configuration, you can store remark configuration in a separate file instead ofpackage.json. remark-cli searches upward from each processed file and supports several formats.
Here is the equivalent JavaScript configuration in .remarkrc.js:
.remarkrc.yml:
.remarkrc, .remarkrc.cjs, .remarkrc.json, .remarkrc.js, .remarkrc.mjs, .remarkrc.yaml, .remarkrc.yml, and the remarkConfig field in package.json.
Formatting markdown automatically
remark-lint reports issues, but remark can also fix many style inconsistencies automatically by re-serializing the file throughremark-stringify. Add --output to the CLI command to rewrite files in place:
Next steps
Creating Plugins
Write custom lint rules or transformations as remark plugins.
Security
Understand the security implications of processing untrusted markdown.