remark-lint-heading-length

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

A remark-lint rule to enforce a minimum and maximum number of words in headings in Markdown files. Version 1.0.0 is the current stable release, based on the unified ecosystem. It allows configuration of min and max word counts, with defaults of 2 and 10 respectively. Unlike generic linters, this rule is specific to heading length and integrates seamlessly with remark-lint presets.

error Error: Cannot find module 'remark-lint-heading-length'
cause Package not installed or missing from dependencies.
fix
Run: npm install remark-lint-heading-length
error TypeError: plugin is not a function
cause Importing the package incorrectly (e.g., destructuring a non-default export).
fix
Use default import: import remarkLintHeadingLength from 'remark-lint-heading-length'
error Error: Illegal configuration for remark-lint-heading-length
cause Passing configuration as a plain object instead of array.
fix
Use array format: ['error', { min: 2, max: 10 }]
gotcha Configuration must be an array with severity and options; passing plain object fails silently.
fix Use array format: [severity, options] or just severity string.
gotcha Default min/max may not suit all projects; headings like 'Introduction' (1 word) will trigger warnings.
fix Configure min to 1 if single-word headings are acceptable.
deprecated This package is part of the deprecated remark-lint v8 line; consider migrating to unified and eslint-plugin-markdown.
fix Use eslint-plugin-markdown or unified-based linters instead.
npm install remark-lint-heading-length
yarn add remark-lint-heading-length
pnpm add remark-lint-heading-length

Configures remark-lint with the heading-length rule, then processes a Markdown string to show linting output.

import { remark } from 'remark';
import remarkLint from 'remark-lint';
import remarkLintHeadingLength from 'remark-lint-heading-length';

const file = await remark()
  .use(remarkLint)
  .use(remarkLintHeadingLength, ['error', { min: 3, max: 12 }])
  .process('# Too short');

console.log(file.messages); // Message: Heading must have at least 3 words