lasselupe33 / eslint-plugin-comment-length

MIT License
13 stars 3 forks source link

[Feature] Logical line wrapping #7

Closed CreativeTechGuy closed 11 months ago

CreativeTechGuy commented 12 months ago

Currently line are wrapped purely "scientifically" at word boundaries. This often makes the formatted comments hard to read as sentences are broken up at weird places in the middle.

I'd like to propose a setting (possibly also default) to opt for wrapping at logical pauses in the sentences.

The algorithm would look like:

During the wrapping algorithm which steps through word by word...

This results in a much more readable comment as sentences will be less likely to be broken across lines unnecessarily. And it also more closely matches how a human would wrap manually since they would opt to put a line break at a logical place for readability.

This also has the nice side effect that it greatly reduces the number of times a single word will be on a line by itself due to wrapping.


I've developed a prototype implementation of this and would be willing to implement it if this is accepted.

lasselupe33 commented 11 months ago

Hi @CreativeTechGuy, thanks for your detailed issue!

While I understand your argument and see that it may increase readability in several cases, I disagree that splitting sentences in the 'middle' outright decreases readability. We've used this plugin internally for a long time, and we enjoy the wrapping as is. In a book lines are rarely split by sentence, and here it is perfectly acceptable to split when reaching the end of the line, while still being completely readable.

As this project has been developed for internal use, and since our preference differs, I will keep the default wrapping logic as it always have been. However, I appreciate your prototype, and I understand that many people may benefit from this feature, and as such it will be merged and released soon (based on your PR). Please refer to #8 for additional information :).