Skip to content

feat(prettier-sentences-per-line): add option to define abbreviations - #815

Merged
JoshuaKGoldberg merged 7 commits into
JoshuaKGoldberg:mainfrom
michaelfaith:fix/abbreviations
Dec 19, 2025
Merged

JoshuaKGoldberg merged 7 commits into
JoshuaKGoldberg:mainfrom
michaelfaith:fix/abbreviations

Conversation

@michaelfaith

Copy link
Copy Markdown
Contributor

PR Checklist

Overview

This change addresses a bug where new lines were triggered after abbreviations like e.g.. In addition to covering well-known cases, there's a new option to provide your own custom options. By providing knownAbbreviations you can either override or extend the default set of known abbreviations. See the README for more information.

@michaelfaith
michaelfaith marked this pull request as ready for review December 11, 2025 12:10
@michaelfaith

Copy link
Copy Markdown
Contributor Author

@JoshuaKGoldberg open to other ideas for the naming of the new option. I'm not married to knownAbbreviations 馃槃

@JoshuaKGoldberg JoshuaKGoldberg left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

馃啋! I have some questions+thoughts about the defaulting design, WDYT?

Comment thread packages/prettier-plugin-sentences-per-line/src/index.ts Outdated
Comment thread packages/prettier-plugin-sentences-per-line/README.md Outdated
Comment thread packages/prettier-plugin-sentences-per-line/src/index.ts
@JoshuaKGoldberg JoshuaKGoldberg added the status: waiting for author Needs an action taken by the original poster label Dec 13, 2025
@JoshuaKGoldberg

Copy link
Copy Markdown
Owner

Oh and also, this is also related to #27 right?

@michaelfaith

michaelfaith commented Dec 13, 2025 •

Copy link
Copy Markdown
Contributor Author

Oh and also, this is also related to #27 right?

I don't think so. If I understand the history of this repo correctly, that issue was originally created when sentences-per-line was just the markdown plugin. So that issue is more for the markdown plugin? This change is for the prettier plugin. (may be worth making that clear in the issue, since the repo didn't used to have multiple packages?)

@github-actions github-actions Bot removed the status: waiting for author Needs an action taken by the original poster label Dec 14, 2025
@michaelfaith

Copy link
Copy Markdown
Contributor Author

@JoshuaKGoldberg these build failures will be resolved by: #826, so that needs to land first.

@JoshuaKGoldberg JoshuaKGoldberg left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking good! Just requesting changes on the as string[] validation request. I left a couple other comments/questions inline too.

Comment thread packages/prettier-plugin-sentences-per-line/README.md Outdated
Comment thread packages/sentences-per-line/package.json
Comment thread packages/prettier-plugin-sentences-per-line/src/index.ts Outdated
@JoshuaKGoldberg JoshuaKGoldberg added the status: waiting for author Needs an action taken by the original poster label Dec 17, 2025
This change addresses a bug where new lines were triggered after abbreviations like `e.g.`.  In addition to covering well-known cases, there's a new option to provide your own custom options.  By providing `knownAbbreviations` you can either override or extend the default set of known abbreviations.  See the README for more information.
changed option to extend the standard set of abbreviations instead of replacing them
This change exposes a new function from the `sentences-per-line` package to determine if the line of text ends with an ignored word.

It also updates both prettier-plugin-sentences-per-line to use this new function.

In order to support this, I updated the `sentences-per-line` plugin to use `publishConfig`, and referenced the package from `prettier-plugin-sentences-per-line` with workspace protocol.  That way, local development will use the source (no longer requiring a build happen), while the published package will get the properties for the built js.
@github-actions github-actions Bot removed the status: waiting for author Needs an action taken by the original poster label Dec 19, 2025

@JoshuaKGoldberg JoshuaKGoldberg left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

馃挴 thanks as always @michaelfaith! It's always a pleasure seeing you pop up in a new repository and do great work.

@JoshuaKGoldberg
JoshuaKGoldberg merged commit 586e9f1 into JoshuaKGoldberg:main Dec 19, 2025
10 checks passed
@JoshuaKGoldberg

Copy link
Copy Markdown
Owner

@michaelfaith
michaelfaith deleted the fix/abbreviations branch December 19, 2025 19:10
JoshuaKGoldberg added a commit that referenced this pull request Aug 19, 2026
## PR Checklist

- [x] Addresses an existing open issue: fixes #27
- [x] That issue was marked as [`status: accepting
prs`](https://github.com/JoshuaKGoldberg/sentences-per-line/issues?q=is%3Aopen+is%3Aissue+label%3A%22status%3A+accepting+prs%22)
- [x] Steps in
[CONTRIBUTING.md](https://github.com/JoshuaKGoldberg/sentences-per-line/blob/main/.github/CONTRIBUTING.md)
were taken

## Overview

Makes the list of ignored abbreviations configurable in every plugin, so
docs in other languages can add their own (e.g. French `Mme.`).

| Package | Option | Configured in |
| :------------------------------------- |
:----------------------------------------- |
:------------------------------------- |
| `eslint-plugin-sentences-per-line` | `additionalAbbreviations` | The
`one` rule's options object |
| `markdownlint-sentences-per-line` | `additional_abbreviations` | The
rule's markdownlint config object |
| `prettier-plugin-sentences-per-line` |
`sentencesPerLineAdditionalAbbreviations` | Prettier config (already on
`main`) |

### `sentences-per-line`

`getIndexBeforeSecondSentence` now takes an optional second
`customIgnoredWords` parameter that it forwards to
`doesEndWithIgnoredWord`, which already supported extra words but had no
caller path from this function.

### `eslint-plugin-sentences-per-line`

The `one` rule had `schema: []`, so it now has a real options object
with `additionalProperties: false`, typed through the
`MarkdownRuleDefinition` options generic (no casts):

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

### `markdownlint-sentences-per-line`

The rule reads an `additional_abbreviations` array of strings out of its
own markdownlint config (`params.config`), matching the `snake_case`
keys markdownlint's built-in rules use (`line_length`, `code_blocks`,
`ignore_words`).

```json
{
	"markdownlint-sentences-per-line": {
		"additional_abbreviations": ["Mme."]
	}
}
```

### `prettier-plugin-sentences-per-line`

Previously done by #815.

馃挅

馃 Generated with [Claude Code](https://claude.com/claude-code)

---------

Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

馃悰 Bug: prettier-plugin-sentences-per-line causes line break after "e.g." and "vs."

2 participants