Skip to content

Latest commit

 

History

History

README.md

eslint-plugin-sentences-per-line

🤝 Code of Conduct: Kept 📝 License: MIT 📦 npm version 💪 TypeScript: Strict

ESLint plugin for limiting sentences per line. 📐

eslint-plugin-sentences-per-line allows you to enforce that no line in your Markdown files contains more than one sentence. This is useful because:

  • Shorter lines result in simpler, easier-to-understand Git diffs
  • Longer lines are harder to read in source code
- First sentence. Second sentence.
+ First sentence.
+ Second sentence.

Usage

👉 This ESLint plugin assumes you're using @eslint/markdown.

First install this package as a devDependency:

npm i -D eslint-plugin-sentences-per-line

Then add the following options to your ESLint configuration file:

import markdown from "@eslint/markdown";
import sentencesPerLine from "eslint-plugin-sentences-per-line";

export default [
	// your other ESLint configurations
	{
		extends: [
			markdown.configs.recommended,
			// 👇 Apply this config to your *.md files
			sentencesPerLine.configs.recommended,
		],
		files: ["**/*.md"],
	},
];

Sentences within Markdown table rows are left alone, as splitting a row across lines would break the table.

Options

additionalAbbreviations

An array of custom abbreviations to ignore when determining sentence boundaries.

These will be added to the standard list of abbreviations below.

["eg.", "e.g.", "etc.", "ex.", "ie.", "i.e.", "vs."]

export default [
	{
		rules: {
			"sentences-per-line/one": [
				"error",
				{ additionalAbbreviations: ["Mme."] },
			],
		},
	},
];

locale

The BCP 47 locale tag describing the language your Markdown is written in.

Defaults to "en-US".

export default [
	{
		rules: {
			"sentences-per-line/one": ["error", { locale: "el" }],
		},
	},
];

Rules

💼 Configurations enabled in.
✅ Set in the recommended configuration.
🔧 Automatically fixable by the --fix CLI option.

Name Description 💼 🔧
one Limits Markdown sentences to one per line. ✅ 🔧

Alternatives

This package is part of the sentences-per-line family of packages. You might also consider: