Repository navigation
feat(prettier-sentences-per-line): add option to define abbreviations - #815
Conversation
|
@JoshuaKGoldberg open to other ideas for the naming of the new option. I'm not married to |
JoshuaKGoldberg
left a comment
There was a problem hiding this comment.
馃啋! I have some questions+thoughts about the defaulting design, WDYT?
|
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 |
|
@JoshuaKGoldberg these build failures will be resolved by: #826, so that needs to land first. |
JoshuaKGoldberg
left a comment
There was a problem hiding this comment.
Looking good! Just requesting changes on the as string[] validation request. I left a couple other comments/questions inline too.
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.
d605fbe to
3481622
Compare
JoshuaKGoldberg
left a comment
There was a problem hiding this comment.
馃挴 thanks as always @michaelfaith! It's always a pleasure seeing you pop up in a new repository and do great work.
## 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>
PR Checklist
status: accepting prsOverview
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 providingknownAbbreviationsyou can either override or extend the default set of known abbreviations. See the README for more information.