Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Line break before JSDoc blocks #1209

Closed
thernstig opened this issue Feb 29, 2024 · 9 comments · Fixed by #1289 · May be fixed by Sec32fun32/eslint#3 or OKEAMAH/eslint#36
Closed

Line break before JSDoc blocks #1209

thernstig opened this issue Feb 29, 2024 · 9 comments · Fixed by #1289 · May be fixed by Sec32fun32/eslint#3 or OKEAMAH/eslint#36

Comments

@thernstig
Copy link

Motivation

It would be nice to always force line breaks before /** blocks as code reads nicer that way, akin to chapters in a book.

Current behavior

There is no such rule.

Desired behavior

To add such rule.

Alternatives considered

https://eslint.style/rules/js/lines-around-comment exists, and maybe I should use that instead? But I wrote this anyway as this package is about specifically JSDoc. I am fine however to use https://eslint.style/rules/js/lines-around-comment if there is no interest to include it here.

brettz9 added a commit to brettz9/eslint-plugin-jsdoc that referenced this issue Aug 4, 2024
brettz9 added a commit to brettz9/eslint-plugin-jsdoc that referenced this issue Aug 4, 2024
brettz9 added a commit to brettz9/eslint-plugin-jsdoc that referenced this issue Aug 4, 2024
BREAKING CHANGE:

Adds new rule to recommended
brettz9 added a commit to brettz9/eslint-plugin-jsdoc that referenced this issue Aug 4, 2024
BREAKING CHANGE:

Adds new rule to recommended
brettz9 added a commit to brettz9/eslint-plugin-jsdoc that referenced this issue Aug 4, 2024
BREAKING CHANGE:

Adds new rule to recommended
brettz9 added a commit to brettz9/eslint-plugin-jsdoc that referenced this issue Aug 5, 2024
BREAKING CHANGE:

Adds new rule to recommended
brettz9 added a commit to brettz9/eslint-plugin-jsdoc that referenced this issue Aug 5, 2024
BREAKING CHANGE:

Adds new rule to recommended
brettz9 added a commit to brettz9/eslint-plugin-jsdoc that referenced this issue Aug 6, 2024
BREAKING CHANGE:

Adds new rule to recommended
brettz9 added a commit that referenced this issue Aug 6, 2024
BREAKING CHANGE:

Adds new rule to recommended
Copy link

github-actions bot commented Aug 6, 2024

🎉 This issue has been resolved in version 49.0.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

@lamuertepeluda
Copy link

Using this with prettier is at least trickier. It should have been disabled by default

@thernstig
Copy link
Author

@lamuertepeluda I have not updated to test the new rule yet, but when I wrote these we were using Prettier (and still are) and it did not handle this, otherwise I would most likely not have written the post.

Or are you saying Prettier does handle this with a line break before JSDoc comment blocks, and I must have just done something awfully wrong to miss that?

@brettz9
Copy link
Collaborator

brettz9 commented Aug 13, 2024

I wouldn't expect this would have problems with Prettier if properly implemented. However, we had two issues (#1295 and #1296), so the rule turned out to just not be ready.

@lamuertepeluda
Copy link

lamuertepeluda commented Aug 13, 2024

@lamuertepeluda I have not updated to test the new rule yet, but when I wrote these we were using Prettier (and still are) and it did not handle this, otherwise I would most likely not have written the post.

Or are you saying Prettier does handle this with a line break before JSDoc comment blocks, and I must have just done something awfully wrong to miss that?

sorry I didn't mention that I am using prettier + https://www.npmjs.com/package/prettier-plugin-jsdoc in my previous post

and that it was like prettier removing the line and eslint adding the line with this rule enabled (or the other way around, sorry I am currently on a week off so I cannot check on my PC 😅). We have both prettier and eslint hooks on save.
Disabling this rule solved my issue but I was surprised once I updated this plugin

@thernstig
Copy link
Author

thernstig commented Aug 13, 2024

@lamuertepeluda I do not think this plugin here can take into account all other plugins that exist, such as https://www.npmjs.com/package/prettier-plugin-jsdoc which is not wildly used either. I think you need to disable the rule as you did.

I like that this was added as default by @brettz9 (albeit of course fixing the two above bugs would be nice).

@brettz9
Copy link
Collaborator

brettz9 commented Aug 13, 2024

I have since removed the rule from the recommended rules until such time as we may fix the bugs. At such a time, I would like to move the rule back (as again, I don't think it should conflict with prettier since it should just be adding a line, and prettier shouldn't need to collapse lines around JSDoc--at least I've never seen that happen).

@lamuertepeluda
Copy link

@lamuertepeluda I do not think this plugin here can take into account all other plugins that exist, such as https://www.npmjs.com/package/prettier-plugin-jsdoc which is not wildly used either. I think you need to disable the rule as you did.

I like that this was added as default by @brettz9 (albeit of course fixing the two above bugs would be nice).

Agreed but for backward compatibility I would have expected it to be off by default.

Anyways, thanks for your hard work on this plugin 🙌 and if anyone else is having such issues with prettier can just turn this rule off.

@brettz9
Copy link
Collaborator

brettz9 commented Aug 13, 2024

@lamuertepeluda I do not think this plugin here can take into account all other plugins that exist, such as https://www.npmjs.com/package/prettier-plugin-jsdoc which is not wildly used either. I think you need to disable the rule as you did.
I like that this was added as default by @brettz9 (albeit of course fixing the two above bugs would be nice).

Agreed but for backward compatibility I would have expected it to be off by default.

It was released as part of a semantic major version, so breaking changes should be expected in such cases. But again, there were some issues with the rule, so disabling for now.

Anyways, thanks for your hard work on this plugin 🙌

Thank you.

and if anyone else is having such issues with prettier can just turn this rule off.

Sure.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment