remark-lint-linebreak-style
raw JSON → 4.0.1 verified Fri May 01 auth: no javascript
remark-lint rule to warn when line endings (linebreaks) violate a given or detected style. Version 4.0.1 is the current stable release. It is part of the remark-lint ecosystem and is ESM-only (Node.js 16+). Provides configurable detection of consistent line endings (unix LF or windows CRLF) and can auto-detect the first used style. Ships TypeScript type definitions. Ideal for ensuring consistent line endings across markdown files.
Common errors
error Error [ERR_REQUIRE_ESM]: require() of ES Module ↓
cause Package is ESM-only; CommonJS require() is used.
fix
Replace require() with import statement, or use dynamic import().
error TypeError: Cannot read properties of undefined (reading 'type') ↓
cause Plugin used without first configuring remark-lint or missing remarkParse/remarkStringify.
fix
Ensure unified().use(remarkParse).use(remarkLint).use(...) chain is correct.
Warnings
breaking Version 4+ is ESM-only; CommonJS require() will throw. ↓
fix Switch to import syntax or use dynamic import().
deprecated No deprecated versions known.
gotcha The 'consistent' option auto-detects the first line ending and warns on subsequent mismatches. It does not enforce a specific style. ↓
fix Use 'unix' or 'windows' explicitly if consistent enforcement is needed.
gotcha remark-stringify always outputs Unix line endings (LF), regardless of the lint configuration. This plugin only warns, it does not fix. ↓
fix Use a separate tool (e.g., text editor settings) to enforce final output line endings.
Install
npm install remark-lint-linebreak-style yarn add remark-lint-linebreak-style pnpm add remark-lint-linebreak-style Imports
- remarkLintLinebreakStyle wrong
const remarkLintLinebreakStyle = require('remark-lint-linebreak-style')correctimport remarkLintLinebreakStyle from 'remark-lint-linebreak-style' - Options (type)
import type { Options } from 'remark-lint-linebreak-style' - Style (type)
import type { Style } from 'remark-lint-linebreak-style'
Quickstart
import remarkLint from 'remark-lint'
import remarkLintLinebreakStyle from 'remark-lint-linebreak-style'
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(remarkLintLinebreakStyle, 'unix')
.use(remarkStringify)
.process(file)
console.error(reporter(file))