remark-lint-maximum-line-length
raw JSON → 4.1.1 verified Fri May 01 auth: no javascript
A remark-lint rule that warns when lines in Markdown files exceed a configurable maximum length. Version 4.1.1 is the current stable release, part of the remark-lint monorepo. It is ESM-only, requires Node.js 16+, and ships TypeScript types. Unlike general linters, it respects Markdown node types (e.g., ignores code blocks, tables, and long URLs/links that cannot be wrapped). Supports a custom stringLength function for accurate character width measurement. Active development, updated regularly with other remark-lint packages.
Common errors
error Cannot find module 'remark-lint-maximum-line-length' ↓
cause Package not installed or incorrect import path.
fix
Run 'npm install remark-lint-maximum-line-length' and ensure you use the default import.
error ERR_REQUIRE_ESM ↓
cause Using require() on an ESM-only package.
fix
Change to import statement or use dynamic import().
error TypeError: remarkLintMaximumLineLength is not a function ↓
cause Using a named import instead of default import.
fix
Use 'import remarkLintMaximumLineLength from ...' (without braces).
error TypeError: Cannot read properties of undefined (reading 'type') ↓
cause Missing remark-parse or remark-lint plugin in the pipeline.
fix
Ensure you use remarkParse and remarkLint before the rule.
Warnings
breaking Package is ESM-only since v3. CommonJS require() will throw an error. ↓
fix Use import statement instead of require(). If you must use CommonJS, use dynamic import() or stay on v2.x.
breaking Default options changed from size=80 to size=60 in v4. ↓
fix Explicitly set size option if you expect 80 characters.
deprecated The option 'maxLineLength' was renamed to 'size' in v4. ↓
fix Use the 'size' option instead of 'maxLineLength'.
gotcha The rule ignores nodes that cannot be wrapped (e.g., code blocks, tables, long URLs). Users may expect warnings for all lines. ↓
fix No fix; this is by design. Review the documentation to understand which lines are checked.
gotcha The CLI plugin name must use kebab-case: 'remark-lint-maximum-line-length', not camelCase. ↓
fix Use the correct kebab-case name in CLI commands.
Install
npm install remark-lint-maximum-line-length yarn add remark-lint-maximum-line-length pnpm add remark-lint-maximum-line-length Imports
- remarkLintMaximumLineLength wrong
const { remarkLintMaximumLineLength } = require('remark-lint-maximum-line-length')correctimport remarkLintMaximumLineLength from 'remark-lint-maximum-line-length' - Options
import type { Options } from 'remark-lint-maximum-line-length' - remarkLintMaximumLineLength (CLI usage) wrong
remark --use remarkLintMaximumLineLengthcorrectremark --use remark-lint-maximum-line-length
Quickstart
import { unified } from 'unified';
import remarkParse from 'remark-parse';
import remarkStringify from 'remark-stringify';
import remarkLint from 'remark-lint';
import remarkLintMaximumLineLength from 'remark-lint-maximum-line-length';
import { read } from 'to-vfile';
import { reporter } from 'vfile-reporter';
const file = await read('example.md');
const result = await unified()
.use(remarkParse)
.use(remarkLint)
.use(remarkLintMaximumLineLength, { size: 80 })
.use(remarkStringify)
.process(file);
console.error(reporter(result));