Registry / testing / remark-lint-hard-break-spaces

remark-lint-hard-break-spaces

JSON →
library4.1.1jsnpmunverified

A remark-lint rule to warn when too many spaces are used to create a hard break (line break) in Markdown. Current stable version: 4.1.1 (ESM-only, TypeScript types included). Release cadence: follows remark-lint monorepo releases. Key differentiators: as part of the official remark-lint ecosystem, it integrates seamlessly with unified/remark and supports presets like remark-preset-lint-recommended. It enforces consistent hard break style (exactly 2 trailing spaces) and can optionally disallow space-based hard breaks entirely in favor of backslash escapes.

npm install remark-lint-hard-break-spaces
INSTALL
IMPORT
SIG · REMARK-LINT-HARD-B
R
remark-lint-hard-break-spaces
testingjavascriptv4.1.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.

remarkLintHardBreakSpaces
import remarkLintHardBreakSpaces from 'remark-lint-hard-break-spaces'
const remarkLintHardBreakSpaces = require('remark-lint-hard-break-spaces')
ESM-only since v4. CommonJS require() will throw an error.
Options
import type { Options } from 'remark-lint-hard-break-spaces'
import { Options } from 'remark-lint-hard-break-spaces'
Options is a TypeScript type, not a runtime export. Use type import to avoid bundler warnings.
default export
import remarkLintHardBreakSpaces from 'remark-lint-hard-break-spaces'
import { remarkLintHardBreakSpaces } from 'remark-lint-hard-break-spaces'
This package only has a default export. Named imports (other than type) are incorrect.

Lints a Markdown file using remark, with the hard-break-spaces rule configured to disallow trailing space hard breaks (enforce backslash).

import { read } from 'to-vfile'; import { reporter } from 'vfile-reporter'; import { unified } from 'unified'; import remarkParse from 'remark-parse'; import remarkStringify from 'remark-stringify'; import remarkLint from 'remark-lint'; import remarkLintHardBreakSpaces from 'remark-lint-hard-break-spaces'; const file = await unified() .use(remarkParse) .use(remarkLint) .use(remarkLintHardBreakSpaces, { allowSpaces: false }) .use(remarkStringify) .process(await read('example.md')); console.error(reporter(file));
Debug
Known issues
breakingVersion 4.0.0 dropped CommonJS support. The package is now ESM-only.
fix
Use dynamic import() or switch to an ESM project. If you must use CommonJS, stay on v3.x.
affects: >=4.0.0
breakingThe default export was renamed (previously exported as `remarkLintHardBreakSpaces`). In v4, the default export is the plugin function directly.
fix
Use `import remarkLintHardBreakSpaces from 'remark-lint-hard-break-spaces'` instead of `import { default } from ...`.
affects: >=4.0.0
deprecatedThe `allowSpaces` option default may change in future major versions to encourage backslash escapes per CommonMark recommendation.
fix
Explicitly set `{ allowSpaces: true/false }` to avoid surprises in future upgrades.
affects: >=4.0.0
gotchaRequires `remark-lint` to be used as a plugin before this rule in the unified pipeline; otherwise the rule has no effect.
fix
Ensure `.use(remarkLint)` is called before `.use(remarkLintHardBreakSpaces)`.
affects: >=3.0.0
gotchaThis rule only checks trailing spaces; it does not warn about hard breaks created by backslash escapes, which are always allowed unless `allowSpaces: false` is set.
fix
Use `allowSpaces: false` to require backslash escapes for hard breaks.
affects: >=3.0.0
gotchaThe rule does not detect hard breaks in code blocks or raw HTML; it applies only to standard Markdown block/span content.
fix
This is by design. If you need to lint inside code comments or HTML, use a separate plugin.
affects: >=3.0.0
Errors
Common errors & fixes
Error: Cannot find module 'remark-lint-hard-break-spaces'
Package not installed or incorrect import path.
fix
Run `npm install remark-lint-hard-break-spaces` and ensure the import path matches the package name.
ERR_REQUIRE_ESM: require() of ES Module /node_modules/remark-lint-hard-break-spaces/index.js from ... not supported.
Using CommonJS require() on an ESM-only package (v4+).
fix
Use `import remarkLintHardBreakSpaces from 'remark-lint-hard-break-spaces'` in an ESM context, or downgrade to v3.x.
TypeError: remarkLintHardBreakSpaces is not a function
Wrong import style (named import instead of default import).
fix
Use `import remarkLintHardBreakSpaces from 'remark-lint-hard-break-spaces'` (no curly braces).
Error: The plugin `remark-lint-hard-break-spaces` does not export a `default` property.
Attempting to use the plugin with a configuration object that expects a named export.
fix
Ensure the plugin is referenced correctly in `.use()`: `unified().use(remarkLintHardBreakSpaces)`.
Upgrade
Version history
4.1.1latest on npm
Audit
Dependencies
unified-lint-rulerequiredUsed internally to define the lint rule.
Agent activity
2 hits · last 30 days
node
2
Resources
remark-lint-hard-break-spaces — npm install remark-lint-hard-break-spaces · libregistry