remark-preset-lint-recommended
raw JSON → 7.0.1 verified Fri May 01 auth: no javascript
A preset for remark-lint that configures a set of recommended rules to catch common problems in markdown files. Current stable version is 7.0.1 (ESM-only, requires Node.js 16+). Part of the unified/remark ecosystem, it bundles 15+ lint rules including checks for final newline, hard break spaces, undefined references, and more. Differentiators: opinionated but minimal set of rules that aim to prevent mistakes and ensure cross-vendor compatibility; ships TypeScript types; actively maintained as part of the remark-lint monorepo.
Common errors
error TypeError: remarkPresetLintRecommended is not a function ↓
cause Incorrect import (named import instead of default) or trying to call the preset as a function without using .use().
fix
Use default import: import remarkPresetLintRecommended from 'remark-preset-lint-recommended'. Then use with .use(remarkPresetLintRecommended).
error Cannot find module 'remark-preset-lint-recommended' ↓
cause Package not installed or used in a CommonJS environment with require().
fix
Install: npm install remark-preset-lint-recommended. If using CommonJS, transpile or update to ESM.
error Error: Cannot find module 'remark-lint' ↓
cause Missing peer dependency; remark-preset-lint-recommended requires remark-lint to be installed.
fix
Install remark-lint as a direct dependency: npm install remark-lint.
Warnings
breaking Version 7 drops CommonJS support; package is ESM-only and requires Node.js 16+. ↓
fix Switch to ESM imports (import) and ensure Node >= 16.
gotcha The preset includes many sub-packaged remark-lint plugins; they are automatically installed but not individually configurable via the preset. To change plugin options, use the individual plugins directly. ↓
fix If you need to customize a rule, import the specific plugin (e.g., remark-lint-final-newline) and configure it separately.
gotcha The preset uses remark-lint ordered list marker style with '.' by default. This may conflict with some Markdown style guides that prefer ')'. ↓
fix Override by importing remark-lint-ordered-list-marker-style with the desired option: .use(remarkLintOrderedListMarkerStyle, ')').
Install
npm install remark-preset-lint-recommended yarn add remark-preset-lint-recommended pnpm add remark-preset-lint-recommended Imports
- remarkPresetLintRecommended wrong
const remarkPresetLintRecommended = require('remark-preset-lint-recommended')correctimport remarkPresetLintRecommended from 'remark-preset-lint-recommended' - remarkPresetLintRecommended (default import) wrong
import { remarkPresetLintRecommended } from 'remark-preset-lint-recommended'correctimport remarkPresetLintRecommended from 'remark-preset-lint-recommended' - remarkPresetLintRecommended (type import) wrong
import remarkPresetLintRecommended from 'remark-preset-lint-recommended' as Presetcorrectimport type { Preset } from 'unified'; import remarkPresetLintRecommended from 'remark-preset-lint-recommended'
Quickstart
import remarkParse from 'remark-parse'
import remarkPresetLintRecommended from 'remark-preset-lint-recommended'
import remarkStringify from 'remark-stringify'
import { unified } from 'unified'
import { reporter } from 'vfile-reporter'
const file = await unified()
.use(remarkParse)
.use(remarkPresetLintRecommended)
.use(remarkStringify)
.process('# Hello world\n\nThis is a test.')
if (file.messages.length > 0) {
console.error(reporter(file))
}
console.log(String(file))