remark-lint-no-heading-indent

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

A remark-lint rule to warn when Markdown headings are indented. Current stable version is 5.0.1, released as part of the remark-lint monorepo. This package is ESM-only (Node.js 16+). It checks that headings have no leading whitespace, enforcing consistent heading style. Unlike other lint rules, it has no options and is recommended to avoid uncommon indentation that can conflict with indented code blocks. The remark-lint ecosystem provides modular, pluggable linting for Markdown files.

error ERR_REQUIRE_ESM
cause Using require() on an ESM-only package.
fix
Change to import statement: import remarkLintNoHeadingIndent from 'remark-lint-no-heading-indent'
error Cannot find module 'unified'
cause Missing peer dependency 'unified'.
fix
Install unified: npm install unified
error TypeError: remarkLintNoHeadingIndent is not a function
cause Using named import instead of default import (e.g., import { remarkLintNoHeadingIndent } from '...')
fix
Use default import: import remarkLintNoHeadingIndent from 'remark-lint-no-heading-indent'
breaking Package is ESM-only starting from v5. CommonJS require() will throw an ERR_REQUIRE_ESM error.
fix Use import syntax or dynamic import(). For Node.js <16, you cannot use this package; upgrade to Node.js 16+.
breaking Peer dependencies (unified, remark-lint) must be installed separately. Missing them causes runtime errors like 'Cannot find module'.
fix Ensure unified and remark-lint are installed: npm install unified remark-lint remark-lint-no-heading-indent.
deprecated The package's default export name changed from 'remarkLintNoHeadingIndent' to the same but with a different internal implementation. No API change, but rely on the documented import path.
fix Update import to current ESM style; old CommonJS usage will break.
gotcha The rule has no options, but users sometimes try to pass an options object (e.g., { severity: 'warning' }). This will be silently ignored.
fix Simply use .use(remarkLintNoHeadingIndent) without arguments.
npm install remark-lint-no-heading-indent
yarn add remark-lint-no-heading-indent
pnpm add remark-lint-no-heading-indent

Set up a unified pipeline with remark-parse, remark-lint, the no-heading-indent rule, and remark-stringify, then process a markdown file and output lint messages.

import remarkLint from 'remark-lint'
import remarkLintNoHeadingIndent from 'remark-lint-no-heading-indent'
import remarkParse from 'remark-parse'
import remarkStringify from 'remark-stringify'
import { read } from 'to-vfile'
import { unified } from 'unified'
import { reporter } from 'vfile-reporter'

const file = await read('example.md')

await unified()
  .use(remarkParse)
  .use(remarkLint)
  .use(remarkLintNoHeadingIndent)
  .use(remarkStringify)
  .process(file)

console.error(reporter(file))