remark-preset-lint-consistent

raw JSON →
6.0.1 verified Fri May 01 auth: no javascript

remark preset that configures remark-lint rules to enforce consistency in Markdown style, such as blockquote indentation, emphasis marker, heading style, list marker style, and table cell padding. Current stable version is 6.0.1. Part of the remark-lint monorepo, released on npm with ESM-only support since v4. Key differentiator: it provides a zero-config preset for consistent Markdown formatting, complementing other presets like remark-preset-lint-recommended and remark-preset-lint-markdown-style-guide. Actively maintained by the unified collective.

error Error [ERR_REQUIRE_ESM]: require() of ES Module /path/to/node_modules/remark-preset-lint-consistent/index.js from /path/to/your-file.js not supported.
cause Using CommonJS require() with an ESM-only package (v4+).
fix
Convert your project to ESM (add 'type': 'module' to package.json) or use dynamic import: const m = await import('remark-preset-lint-consistent');
error TypeError: remarkPresetLintConsistent is not a function
cause Importing the preset incorrectly (e.g., using named import) or forgetting to add it to unified().use().
fix
Use default import: import remarkPresetLintConsistent from 'remark-preset-lint-consistent'; then .use(remarkPresetLintConsistent)
error Missing required peer dependency: remark-lint
cause remark-lint is not installed.
fix
Run: npm install remark-lint
breaking remark-preset-lint-consistent v4 dropped support for CommonJS (require). Packages are now ESM-only.
fix Switch to ESM imports and ensure Node.js version >=16.
gotcha The preset uses 'consistent' as the default option for most rules, which may not match your project's current style. It warns about inconsistencies, not a specific style.
fix To enforce a specific style, use individual remark-lint rules with explicit options instead of the preset.
deprecated Some underlying rules like remark-lint-table-cell-padding will be updated in future versions; check compatibility when upgrading.
fix Always pin exact versions of remark-lint packages to avoid unexpected warnings.
gotcha The preset requires remark-lint to be installed as a peer dependency, but it is not automatically installed. Missing peerDependency can cause runtime errors.
fix Ensure remark-lint is in your dependencies: npm install remark-lint
breaking In v5, the internal structure changed: all rules now export a function that must be used with unified().use(). If you were passing options in a different way, it may break.
fix Use the preset as a unified plugin: .use(remarkPresetLintConsistent) without additional configuration.
npm install remark-preset-lint-consistent
yarn add remark-preset-lint-consistent
pnpm add remark-preset-lint-consistent

Process a Markdown file with the preset to check for consistency issues and report them.

import { unified } from 'unified';
import remarkParse from 'remark-parse';
import remarkStringify from 'remark-stringify';
import remarkPresetLintConsistent from 'remark-preset-lint-consistent';
import { reporter } from 'vfile-reporter';
import { read } from 'to-vfile';

const file = await read('example.md');
await unified()
  .use(remarkParse)
  .use(remarkPresetLintConsistent)
  .use(remarkStringify)
  .process(file);

console.error(reporter(file));
// If there are consistency issues, they will be reported.