Registry / testing / remark-lint-no-heading-content-indent

remark-lint-no-heading-content-indent

JSON →
library5.0.1jsnpmunverified

A remark-lint rule that warns when there is extra whitespace between the opening hashes and the content of headings (ATX headings) in Markdown. It enforces a single space after the `#` markers and before the closing `#`s. This package is part of the remark-lint ecosystem, version 5.0.1, ESM-only, ships TypeScript type definitions. It has no dependencies and is recommended for ensuring consistent heading formatting. The rule is included in the `remark-preset-lint-recommended` preset.

npm install remark-lint-no-heading-content-indent
INSTALL
IMPORT
SIG · REMARK-LINT-NO-HEA
R
remark-lint-no-heading-content-indent
testingjavascriptv5.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.

remarkLintNoHeadingContentIndent
import remarkLintNoHeadingContentIndent from 'remark-lint-no-heading-content-indent'
const remarkLintNoHeadingContentIndent = require('remark-lint-no-heading-content-indent')
ESM-only package; CommonJS require is not supported. Use import syntax.
unified
import { unified } from 'unified'
const unified = require('unified')
Needed to create a processor. The unified package is a peer dependency.
remarkParse
import remarkParse from 'remark-parse'
Parses Markdown into a syntax tree.
remarkStringify
import remarkStringify from 'remark-stringify'
Compiles the syntax tree back to Markdown.

Shows how to set up the lint rule with unified, parse a Markdown string with an extra space after the hash, and report the linting error.

import { unified } from 'unified' import remarkParse from 'remark-parse' import remarkStringify from 'remark-stringify' import remarkLint from 'remark-lint' import remarkLintNoHeadingContentIndent from 'remark-lint-no-heading-content-indent' import { reporter } from 'vfile-reporter' const file = await unified() .use(remarkParse) .use(remarkLint) .use(remarkLintNoHeadingContentIndent) .use(remarkStringify) .process('# Bad heading\n\n## Good heading') console.error(reporter(file)) // 1:4: Unexpected `2` spaces between hashes and content, expected `1` space, remove `1` space
Debug
Known issues
breakingVersion 4.0.0 and later require ESM imports. CommonJS `require()` will fail.
fix
Replace `const x = require('remark-lint-no-heading-content-indent')` with `import x from 'remark-lint-no-heading-content-indent'`
affects: >=4.0.0
gotchaThe rule only checks ATX headings (starting with #) and does not affect setext headings (underlined with === or ---). Indented hash characters inside setext headings are not flagged.
fix
Use ATX headings if you want consistent indentation linting. Setext headings are ignored by design.
affects: >=1.0.0
gotchaThe rule expects exactly one space between hashes and content; leading whitespace before the hashes is also checked: extra spaces before the opening hashes count as indentation that may not match the expected single space after hashes.
fix
Ensure headings are not indented with extra spaces. The rule expects exactly `# SPACE CONTENT` (or `# SPACE CONTENT SPACE #` for closed ATX).
affects: >=1.0.0
deprecatedVersion 5.0.1 is the latest. No breaking changes since v4 but the package is part of remark-lint that regularly updates peer dependencies.
fix
Upgrade to v5.0.1 to ensure compatibility with unified@11 and remark@15.
affects: <=4.0.1
Errors
Common errors & fixes
Unexpected `N` spaces between hashes and content, expected `1` space, remove `N-1` spaces
Heading content has more than one space after the opening hashes or before the closing hashes.
fix
Edit the heading to have exactly one space after the opening `#`(s) and exactly one space before any closing `#`(s). Example: `# Heading` not `#  Heading`.
Unexpected `N` spaces between content and hashes, expected `1` space, remove `N-1` spaces
Closed ATX heading has more than one space before the closing hashes.
fix
Remove extra spaces before the closing `#`(s). Example: `## Heading ##` not `## Heading  ##`.
Upgrade
Version history
5.0.1latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
5 hits · last 30 days
node
4
Resources
remark-lint-no-heading-content-indent — npm install remark-lint-no-heading-content-indent · libregistry