prettier-plugin-sentences-per-line

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

A Prettier plugin that enforces a maximum of one sentence per line in Markdown files. Current stable version is 0.2.3, with frequent releases. It uses the sentences-per-line core to parse sentence boundaries and supports custom abbreviations. Unlike the ESLint or markdownlint counterparts, this plugin integrates directly into the Prettier formatting pipeline, automatically fixing line breaks. It requires Prettier 3 and ships with TypeScript declarations.

error Error: Cannot find module 'prettier-plugin-sentences-per-line'
cause The package is not installed or is not in node_modules.
fix
Run npm install -D prettier-plugin-sentences-per-line and ensure it's in devDependencies.
error Unexpected token 'export'
cause CommonJS environment (e.g., .prettierrc.cjs with require) importing an ESM-only plugin.
fix
Convert your Prettier config to ESM (use .prettierrc.mjs) or use dynamic import: module.exports = { plugins: [await import('prettier-plugin-sentences-per-line')] }
breaking Plugin requires Prettier ^3. Prettier 2.x is not supported.
fix Upgrade Prettier to version 3 or later.
gotcha The plugin is ESM-only; CommonJS require('prettier-plugin-sentences-per-line') will fail.
fix Use dynamic import() or switch to ESM. If using module.require, it will error.
gotcha Option key must be exactly 'sentencesPerLineAdditionalAbbreviations'. Any other casing or typo will be silently ignored.
fix Use the exact key name as documented.
gotcha The plugin only operates on Markdown files (.md). Other file types are ignored.
fix Ensure your file extensions are .md or configure Prettier overrides.
npm install prettier-plugin-sentences-per-line
yarn add prettier-plugin-sentences-per-line
pnpm add prettier-plugin-sentences-per-line

Configures Prettier with the plugin and an additional abbreviation, then shows formatting result splitting multi-sentence lines.

// .prettierrc.json
{
  "plugins": ["prettier-plugin-sentences-per-line"],
  "sentencesPerLineAdditionalAbbreviations": ["e.g.", "i.e."]
}

// Input Markdown:
// First sentence. Second sentence.
// Third sentence.
//
// After formatting via `npx prettier --write input.md`:
// First sentence.
// Second sentence.
// Third sentence.