remark-lint-heading-whitespace
raw JSON → 1.0.0 verified Fri May 01 auth: no javascript
remark-lint rule that detects non-breaking spaces (U+00A0) inserted accidentally after heading markers (e.g., '# ' instead of '# '), which causes headings to be parsed as plain paragraphs. Version 1.0.0 (latest) is stable and targets the remark-lint plugin ecosystem. No known release cadence. Differentiates from other lint rules by focusing on a specific, localization-driven typo that is common on keyboard layouts like Swiss German where '#' is typed via Alt+3 and Alt+Space produces a non-breaking space. Integrates as a remark-lint plugin.
Common errors
error Error [ERR_REQUIRE_ESM]: require() of ES Module not supported ↓
cause Attempting to require() the ESM-only package in a CommonJS context.
fix
Use import() or set 'type':'module' in package.json.
error TypeError: remarkLintHeadingWhitespace is not a function ↓
cause Named import used instead of default import.
fix
Use
import remarkLintHeadingWhitespace from 'remark-lint-heading-whitespace' (default import). Warnings
gotcha Package is ESM-only. Using CommonJS require() will fail with ERR_REQUIRE_ESM. ↓
fix Use dynamic import() or set 'type':'module' in package.json.
gotcha The rule does not automatically apply; it must be added as a plugin to remark with .use(lint) and .use(remarkLintHeadingWhitespace). ↓
fix Ensure both remark-lint and this rule are included in the remark pipeline.
Install
npm install remark-lint-heading-whitespace yarn add remark-lint-heading-whitespace pnpm add remark-lint-heading-whitespace Imports
- default wrong
const remarkLintHeadingWhitespace = require('remark-lint-heading-whitespace')correctimport remarkLintHeadingWhitespace from 'remark-lint-heading-whitespace' - remarkLintHeadingWhitespace wrong
import { remarkLintHeadingWhitespace } from 'remark-lint-heading-whitespace'correctimport remarkLintHeadingWhitespace from 'remark-lint-heading-whitespace'
Quickstart
import { remark } from 'remark';
import lint from 'remark-lint';
import remarkLintHeadingWhitespace from 'remark-lint-heading-whitespace';
const file = await remark()
.use(lint)
.use(remarkLintHeadingWhitespace)
.process('#\u00A0bad heading');
console.log(String(file)); // includes warning about non-breaking space