{"id":26213,"library":"remark-lint-hard-break-spaces","title":"remark-lint-hard-break-spaces","description":"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.","status":"active","version":"4.1.1","language":"javascript","source_language":"en","source_url":"https://github.com/remarkjs/remark-lint#main","tags":["javascript","break","hard","lint","remark","remark-lint","remark-lint-rule","rule","size","typescript"],"install":[{"cmd":"npm install remark-lint-hard-break-spaces","lang":"bash","label":"npm"},{"cmd":"yarn add remark-lint-hard-break-spaces","lang":"bash","label":"yarn"},{"cmd":"pnpm add remark-lint-hard-break-spaces","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Used internally to define the lint rule.","package":"unified-lint-rule","optional":false}],"imports":[{"note":"ESM-only since v4. CommonJS require() will throw an error.","wrong":"const remarkLintHardBreakSpaces = require('remark-lint-hard-break-spaces')","symbol":"remarkLintHardBreakSpaces","correct":"import remarkLintHardBreakSpaces from 'remark-lint-hard-break-spaces'"},{"note":"Options is a TypeScript type, not a runtime export. Use type import to avoid bundler warnings.","wrong":"import { Options } from 'remark-lint-hard-break-spaces'","symbol":"Options","correct":"import type { Options } from 'remark-lint-hard-break-spaces'"},{"note":"This package only has a default export. Named imports (other than type) are incorrect.","wrong":"import { remarkLintHardBreakSpaces } from 'remark-lint-hard-break-spaces'","symbol":"default export","correct":"import remarkLintHardBreakSpaces from 'remark-lint-hard-break-spaces'"}],"quickstart":{"code":"import { read } from 'to-vfile';\nimport { reporter } from 'vfile-reporter';\nimport { unified } from 'unified';\nimport remarkParse from 'remark-parse';\nimport remarkStringify from 'remark-stringify';\nimport remarkLint from 'remark-lint';\nimport remarkLintHardBreakSpaces from 'remark-lint-hard-break-spaces';\n\nconst file = await unified()\n  .use(remarkParse)\n  .use(remarkLint)\n  .use(remarkLintHardBreakSpaces, { allowSpaces: false })\n  .use(remarkStringify)\n  .process(await read('example.md'));\n\nconsole.error(reporter(file));\n","lang":"typescript","description":"Lints a Markdown file using remark, with the hard-break-spaces rule configured to disallow trailing space hard breaks (enforce backslash)."},"warnings":[{"fix":"Use dynamic import() or switch to an ESM project. If you must use CommonJS, stay on v3.x.","message":"Version 4.0.0 dropped CommonJS support. The package is now ESM-only.","severity":"breaking","affected_versions":">=4.0.0"},{"fix":"Use `import remarkLintHardBreakSpaces from 'remark-lint-hard-break-spaces'` instead of `import { default } from ...`.","message":"The default export was renamed (previously exported as `remarkLintHardBreakSpaces`). In v4, the default export is the plugin function directly.","severity":"breaking","affected_versions":">=4.0.0"},{"fix":"Explicitly set `{ allowSpaces: true/false }` to avoid surprises in future upgrades.","message":"The `allowSpaces` option default may change in future major versions to encourage backslash escapes per CommonMark recommendation.","severity":"deprecated","affected_versions":">=4.0.0"},{"fix":"Ensure `.use(remarkLint)` is called before `.use(remarkLintHardBreakSpaces)`.","message":"Requires `remark-lint` to be used as a plugin before this rule in the unified pipeline; otherwise the rule has no effect.","severity":"gotcha","affected_versions":">=3.0.0"},{"fix":"Use `allowSpaces: false` to require backslash escapes for hard breaks.","message":"This 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.","severity":"gotcha","affected_versions":">=3.0.0"},{"fix":"This is by design. If you need to lint inside code comments or HTML, use a separate plugin.","message":"The rule does not detect hard breaks in code blocks or raw HTML; it applies only to standard Markdown block/span content.","severity":"gotcha","affected_versions":">=3.0.0"}],"env_vars":null,"last_verified":"2026-05-01T00:00:00.000Z","next_check":"2026-07-30T00:00:00.000Z","problems":[{"fix":"Run `npm install remark-lint-hard-break-spaces` and ensure the import path matches the package name.","cause":"Package not installed or incorrect import path.","error":"Error: Cannot find module 'remark-lint-hard-break-spaces'"},{"fix":"Use `import remarkLintHardBreakSpaces from 'remark-lint-hard-break-spaces'` in an ESM context, or downgrade to v3.x.","cause":"Using CommonJS require() on an ESM-only package (v4+).","error":"ERR_REQUIRE_ESM: require() of ES Module /node_modules/remark-lint-hard-break-spaces/index.js from ... not supported."},{"fix":"Use `import remarkLintHardBreakSpaces from 'remark-lint-hard-break-spaces'` (no curly braces).","cause":"Wrong import style (named import instead of default import).","error":"TypeError: remarkLintHardBreakSpaces is not a function"},{"fix":"Ensure the plugin is referenced correctly in `.use()`: `unified().use(remarkLintHardBreakSpaces)`.","cause":"Attempting to use the plugin with a configuration object that expects a named export.","error":"Error: The plugin `remark-lint-hard-break-spaces` does not export a `default` property."}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}