Registry / testing / remark-lint-heading-increment

remark-lint-heading-increment

JSON →
library4.0.1jsnpmunverified

A remark-lint rule that warns when heading levels increase by more than one level at a time (e.g., from h1 to h3). This helps enforce accessible heading hierarchies as recommended by HTML accessibility guidelines, where headings should increment by one level. Part of the remark-lint ecosystem, current stable version is 4.0.1 (ESM-only since v2, ships TypeScript types). Released as part of the remark-lint monorepo with regular updates. No options needed. Integrates with remark-lint presets like remark-preset-lint-markdown-style-guide.

npm install remark-lint-heading-increment
INSTALL
IMPORT
SIG · REMARK-LINT-HEADIN
R
remark-lint-heading-increment
testingjavascriptv4.0.1
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

remarkLintHeadingIncrement
import remarkLintHeadingIncrement from 'remark-lint-heading-increment'
const { remarkLintHeadingIncrement } = require('remark-lint-heading-increment')
This package is ESM-only. Default export. CommonJS require is not supported. The function is used as a plugin: .use(remarkLintHeadingIncrement).
remarkLint
import remarkLint from 'remark-lint'
const remarkLint = require('remark-lint')
The remark-lint package is also ESM-only. Must be imported and used before individual lint rules.
unified
import { unified } from 'unified'
const unified = require('unified')
unified package is ESM-only since v10. Use named import.

Shows how to use remark-lint-heading-increment to lint a Markdown file for heading level jumps, outputting any warnings.

import { unified } from 'unified' import remarkParse from 'remark-parse' import remarkStringify from 'remark-stringify' import remarkLint from 'remark-lint' import remarkLintHeadingIncrement from 'remark-lint-heading-increment' import { read } from 'to-vfile' import { reporter } from 'vfile-reporter' const file = await read('example.md') await unified() .use(remarkParse) .use(remarkLint) .use(remarkLintHeadingIncrement) .use(remarkStringify) .process(file) console.error(reporter(file))
Debug
Known issues
breakingPackage is ESM-only; CommonJS require() will fail
fix
Use import or dynamic import() instead of require().
affects: >=3.0.0
deprecatedThe option 'style' was removed in v3.0.0
fix
Remove any 'style' option; this rule now has no options.
affects: >=3.0.0
gotchaWhen using with remark-preset-lint-markdown-style-guide, the preset may already include this rule, causing duplicate warnings
fix
Do not add the rule manually if the preset is used; check preset documentation.
affects: >=1.0.0
breakingTypeScript types changed in v4.0.0 (refactored internal types for option coercion)
fix
If using TypeScript, ensure your project uses @import syntax and upgrade remark-lint types if needed.
affects: >=4.0.0 <5.0.0
gotchaThis rule only works on headings; it does not detect jumps in nested lists or other structures
fix
Combine with other lint rules if needed to enforce consistent structure.
affects: >=1.0.0
Errors
Common errors & fixes
Unexpected heading rank `3`, exected rank `2`
Heading level jumped from h1 to h3 without an h2 in between.
fix
Insert an h2 heading between the h1 and h3, or adjust heading levels to increment by one.
remark-lint-heading-increment is not a function
Using CommonJS require() on ESM-only package.
fix
Use `import remarkLintHeadingIncrement from 'remark-lint-heading-increment'` or set `"type": "module"` in package.json.
ERR_MODULE_NOT_FOUND
Missing dependencies or incorrect import path.
fix
Ensure `remark-lint`, `unified`, `remark-parse`, etc. are installed. Check that the import path is exactly `'remark-lint-heading-increment'`.
Upgrade
Version history
4.0.1latest on npm
Audit
Dependencies
remark-lintrequiredRequired to integrate with the remark linting framework
unifiedrequiredThe plugin is a unified (remark) plugin
Agent activity
4 hits · last 30 days
node
4
Resources
remark-lint-heading-increment — npm install remark-lint-heading-increment · libregistry