remark-lint-heading-word-length
raw JSON → 3.0.0 verified Fri May 01 auth: no javascript
A remark-lint rule that warns when headings contain too many or too few words. Version 3.0.0 is current; breaking change drops Node <20.18.0. Words are split on whitespace. Unlike the archived remark-lint-heading-length, this rule supports configurable min/max word counts. ESM-only. Part of the unified-utils monorepo with semantic-release.
Common errors
error Error [ERR_REQUIRE_ESM]: require() of ES Module ↓
cause Attempting to use CommonJS require() on ESM-only package.
fix
Replace 'const ... = require(...)' with 'import ... from ...'
error TypeError: plugin is not a function ↓
cause Using the full npm package name as plugin key in remark config.
fix
Use 'lint-heading-word-length' instead of 'remark-lint-heading-word-length'.
Warnings
breaking Minimum Node version now 20.18.0 ↓
fix Upgrade Node to 20.18.0 or later.
breaking Package is now ESM-only ↓
fix Switch from require() to import. If you must use CommonJS, consider dynamic import() or stick with v2.x.
deprecated The old 'remark-lint-heading-length' package is archived and no longer maintained ↓
fix Migrate to remark-lint-heading-word-length for active development and new features.
gotcha Plugin short name 'lint-heading-word-length' must be used in config (not full package name) ↓
fix Use 'lint-heading-word-length' in .remarkrc or package.json plugins array.
Install
npm install remark-lint-heading-word-length yarn add remark-lint-heading-word-length pnpm add remark-lint-heading-word-length Imports
- lintHeadingWordLength wrong
const lintHeadingWordLength = require('remark-lint-heading-word-length')correctimport lintHeadingWordLength from 'remark-lint-heading-word-length' - default import wrong
import { lintHeadingWordLength } from 'remark-lint-heading-word-length'correctimport lintHeadingWordLength from 'remark-lint-heading-word-length' - plugin name in config wrong
"remark-lint-heading-word-length"correct"lint-heading-word-length"
Quickstart
import { read } from 'to-vfile';
import { reporter } from 'vfile-reporter';
import { remark } from 'remark';
import remarkLint from 'remark-lint';
import lintHeadingWordLength from 'remark-lint-heading-word-length';
const file = await remark()
.use(remarkLint)
.use(lintHeadingWordLength, { minimumWords: 3, maximumWords: 12 })
.process(await read('example.md'));
console.log(reporter(file));