prettier-plugin-jsdoc: Line breaking happening at 96 print width?

Not sure if this is related to #8 ?

95 characters:

image

96 characters:

image

I’d expect it to wrap such that no characters (including the comment characters) exceed the print width (shown in the screenshot with the vertical line).

This is my .prettierrc:

{
  "plugins": ["./node_modules/prettier-plugin-jsdoc"],
  "jsdocCapitalizeDescription": false,
}

No override of the default printWidth of 80, so it should be 80. Also the rest of my code formats properly to 80.

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Reactions: 1
  • Comments: 17 (14 by maintainers)

Commits related to this issue

Most upvoted comments

what about this

Lorem ipsum is a placeholder text commonly used to demonstrate the visual form of a document or a 
all.

Yes, that is fine, to me.

I understand the issue completely. I just want simple word wrapping, like most word processors do:

Screen Recording 2022-08-11 at 11 17 10 AM (2) Screen Recording 2022-08-11 at 11 17 10 AM (2)

I am willing to bet most other people are just looking for this too. I dont see a reason to make it so complicated with the “fair lines”. It’s cool if you want to add that, but an option for simple word wrapping would be greatly appreciated.

Ok. I Will do it as you want this weekend.

Okay, according to this comment, I guess this was actually a feature:

https://github.com/hosseinmd/prettier-plugin-jsdoc/issues/26#issuecomment-771823206

I was going to say that this was a weird error in judgement. I don’t know of any word processor that tries to “smart” wrap like this. MS Word doesn’t do it. VSCode’s word wrap doesn’t do it. Etc.

However, apparently Prettier does sort of do it:

In other words, don’t try to use printWidth as if it was ESLint’s max-len – they’re not the same. max-len just says what the maximum allowed line length is, but not what the generally preferred length is – which is what printWidth specifies.

Despite all this, I wish there was a way to disable this behavior. I would like to just have it hard wrap at printWidth always. I really think this looks stupid and is unexpected:

image

Also, I can’t verify this, but it seems like Prettier does actually hard wrap at printWidth whenever possible, but sometimes it’s not able to, e.g a long string literal, hence why they say it sometimes produces lines over the printWidth.

Released v0.4.1

I’m sorry for being forceful. I’m guess I’m used to library developers making a baffling decision (in my opinion) and refusing to even consider changing it. But you are not like that. Thank you.

I am working on a PR now for this change. I’ll also tag @egilll in it so that we can coordinate our fixes. I’m not familiar with this code base, so it might be a bad PR, and I’ll still need your help @hosseinmd.

But I should at least create a starting point, since I am the one requesting this change.

I don’t like this feature too, I prefer a new line even if it’s only 1 word on the new line, so I have more consistency in my line widths. But since this is implemented and some people want this, maybe we can turn this into an option that can be configured.