remark-preset-prettier

raw JSON →
2.0.2 verified Sat Apr 25 auth: no javascript

remark-preset-prettier is a unified/remark preset that disables all remark-lint rules which are unnecessary or might conflict with Prettier formatting. Version 2.0.2 is the latest stable release, with a release cadence of patch updates as needed. It ships TypeScript types and requires Node >=14.8. Differentiators: pure ESM via top-level await (since v2), extensive list of disabled plugins (36+), and integration with ESLint or remark-cli. Alternatives require manual configuration to disable each conflicting rule.

error Error: Cannot find module 'remark-preset-prettier'
cause Package not installed or not resolvable in ESM context.
fix
npm install -D remark-preset-prettier
error TypeError: remarkPresetPrettier is not a function
cause Using require in v2 (ESM-only), or incorrect import of named vs default export.
fix
Use import remarkPresetPrettier from 'remark-preset-prettier'
error ERR_REQUIRE_ESM: require() of ES Module /node_modules/remark-preset-prettier/index.js from ... not supported
cause Using require() on an ESM-only package in a CommonJS context.
fix
Switch to import() or use v1.x. For dynamic import: const remarkPresetPrettier = await import('remark-preset-prettier');
error Unsupported top-level await: package.json 'type' is 'commonjs' or .cjs file used.
cause v2 uses top-level await which is only allowed in ESM modules.
fix
Set package.json type:module or rename file to .mjs.
breaking v2.0.0 switched to pure ESM with top-level await. Requires Node >=14.8 and cannot be used with CommonJS require().
fix Migrate to ESM: use import or .mjs extension for config file. If stuck on CJS, use v1.x (<=1.0.2).
deprecated Peer dependency prettier >=1.0.0. Using older Prettier versions may cause unexpected conflicts.
fix Use prettier >=2.0.0 for best compatibility.
gotcha The preset disables many lint rules. Ensure you have remark-lint installed; otherwise the preset has no effect.
fix Install remark-lint and have it in your remark plugins list.
gotcha Remark config files must be ESM (.mjs or .js with type:module) for v2. Using CommonJS config (.js with module.exports) fails.
fix Use .remarkrc.mjs or .remarkrc.js if package.json has type:module.
gotcha If using remark-retext with plugins that conflict with Prettier, you may need additional configuration.
fix Consult the README's section on remark-retext issue.
npm install remark-preset-prettier
yarn add remark-preset-prettier
pnpm add remark-preset-prettier

Shows how to configure remark-preset-prettier in a .remarkrc.mjs file and run it with remark-cli to lint Markdown files with Prettier-friendly rules.

// Ensure you have remark-cli and remark-lint installed
// npm install -D remark-cli remark-lint remark-preset-prettier prettier

// .remarkrc.mjs (ESM config)
export default {
  plugins: [
    'remark-preset-prettier',
    // other remark-lint plugins can be added after
    'remark-lint-no-dead-urls'
  ]
}

// Then run: npx remark --use .remarkrc.mjs README.md
// Prettier formatting will be enforced; remark-lint rules that conflict are disabled.