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.
Common errors
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 }]
Warnings
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.
Install
npm install remark-lint-heading-length yarn add remark-lint-heading-length pnpm add remark-lint-heading-length Imports
- remarkLintHeadingLength wrong
const { remarkLintHeadingLength } = require('remark-lint-heading-length')correctimport remarkLintHeadingLength from 'remark-lint-heading-length' - default wrong
import { default as remarkLintHeadingLength } from 'remark-lint-heading-length'correctimport remarkLintHeadingLength from 'remark-lint-heading-length' - remarkLint wrong
import remarkLint from 'remark-lint'correctimport { remarkLint } from 'remark-lint'
Quickstart
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