remark-lint-no-consecutive-blank-lines

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

A remark-lint rule to warn when multiple blank lines (more than one consecutive blank line) are used in Markdown documents. Version 5.0.1 is the current stable release. It is part of the remark-lint ecosystem and is included in the remark-preset-lint-markdown-style-guide preset. This package is ESM-only (requires Node.js 16+) and ships TypeScript types. Unlike formatters, this tool only lints and does not automatically fix consecutive blank lines.

error require() of ES Module /path/to/node_modules/remark-lint-no-consecutive-blank-lines/index.js from /path/to/file.js not supported.
cause Using CommonJS require() on an ESM-only package.
fix
Change to import statement or set "type": "module" in package.json.
error Error: Cannot find module 'remark-lint-no-consecutive-blank-lines'
cause Package not installed or not in node_modules.
fix
Run npm install remark-lint-no-consecutive-blank-lines.
error TypeError: remarkLintNoConsecutiveBlankLines is not a function
cause Importing as named export instead of default export.
fix
Use import remarkLintNoConsecutiveBlankLines from 'remark-lint-no-consecutive-blank-lines' (no curly braces).
breaking Package is ESM-only since v5; requires Node.js 16+ and cannot be used with CommonJS require().
fix Use import instead of require() and ensure Node.js version >=16.
gotcha The rule must be used after remarkParse and remarkLint in the unified pipeline, and cannot be used standalone.
fix Always include remarkParse, remarkLint, and optionally remarkStringify in the pipeline.
deprecated Older versions (v4 and earlier) used a different default export name or required a different import pattern.
fix Upgrade to v5 and switch to ESM import style.
npm install remark-lint-no-consecutive-blank-lines
yarn add remark-lint-no-consecutive-blank-lines
pnpm add remark-lint-no-consecutive-blank-lines

Shows how to import and use the remark-lint rule to detect too many consecutive blank lines.

import remarkLint from 'remark-lint';
import remarkLintNoConsecutiveBlankLines from 'remark-lint-no-consecutive-blank-lines';
import remarkParse from 'remark-parse';
import remarkStringify from 'remark-stringify';
import { unified } from 'unified';
import { reporter } from 'vfile-reporter';

const file = await unified()
  .use(remarkParse)
  .use(remarkLint)
  .use(remarkLintNoConsecutiveBlankLines)
  .use(remarkStringify)
  .process('# Hello\n\n\nWorld'); // Three blank lines after heading

console.error(reporter(file));
// Output:
//   4:1: Unexpected `2` blank lines before node, expected up to `1` blank line, remove `1` blank line