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

[Multiline block] Enforce text on zero and last lines #830

Closed
SrBrahma opened this issue Jan 14, 2022 · 6 comments
Closed

[Multiline block] Enforce text on zero and last lines #830

SrBrahma opened this issue Jan 14, 2022 · 6 comments

Comments

@SrBrahma
Copy link

SrBrahma commented Jan 14, 2022

Motivation

I have a different taste for JSDoc. Never saw anyone doing it but for me it just looks way better by not having an entire line wasted just for the opener / closer.

Example:

  /** A function that should create your user entry.
   *
   * Resolve it when the function call is concluded.
   *
   * Throwing will call signOut. */
  createUserDbEntry: (params: CreateUserDbEntry) => Promise<any>;

is WAY better (at least for me) than

  /**
   * A function that should create your user entry.
   *
   * Resolve it when the function call is concluded.
   *
   * Throwing will call signOut.
   */
  createUserDbEntry: (params: CreateUserDbEntry) => Promise<any>;

Current behavior

multiline-blocks options allow them, but do no enforce them. Everyday I have to manually fix my JSDocs to fit my taste.

Desired behavior

multiline-blocks options to enforce that /** is proceeded and */ is be preceded with text. They will remove newlines and stars between them and any text.

Alternatives considered

Change my taste. But NO! Lines are too important to be wasted with just two or three meta characters.


Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.

@brettz9
Copy link
Collaborator

brettz9 commented Jan 14, 2022

But the rule should allow for empty descriptions if no next is following, e.g., if there is only a tag?

@SrBrahma
Copy link
Author

SrBrahma commented Jan 14, 2022

Hi @brettz9, thanks for the quick reply!

Like

/**
 * @param foo
 * @param bar
 */

?

I globally searched now in some of my projects and haven't seen any multiline having a tag on the zeroth line, like

/** @param foo
 * @param bar */

It looks awful to me this misalignment, I wouldn't do this at all. You did a nice observation. For texts, it just seems like an ok paragraph, better than wasting an entire line to the opener. The only cases I have a tag on the zeroth line is when it's a single line JSDoc, for @default. Seems that when I have a tag on multilines, I always start with a description text.

Personally, this case is for me a don't care situation as I never did it and certainly never will.

I don't have experience writing ESLint rules, but regarding this, maybe the easiest solution should be done.

@brettz9
Copy link
Collaborator

brettz9 commented Jan 14, 2022

Yes I meant cases like you mention or just:

/**
  * @param foo
  */

or:

/**
  *
  */

I think this shouldn't report anything, as someone wanting to disallow can just use jsdoc/require-description for that. I.e., this should only report and fix if non-tag text is found on the next available line.

@SrBrahma
Copy link
Author

Yes, those seem cases that can be handled by other rules.

@brettz9 brettz9 closed this as completed in d68d742 Nov 2, 2022
@brettz9
Copy link
Collaborator

brettz9 commented Nov 2, 2022

You should now be able to use jsdoc/no-restricted-syntax to get reports if the descriptive text does not begin on the 0th line or end with a new line: d68d742#diff-545a867764ce23fa04a08e7f0207aacd009b8343965ede162d8f09d9b718a844 . Note that there is no fixer, e.g., to collapse any newlines added by the user. But hopefully this should meet your use case. Feel free to comment further if you see any issues targeting the new properties illustrated in the examples.

@gajus
Copy link
Owner

gajus commented Nov 2, 2022

🎉 This issue has been resolved in version 39.6.1 🎉

The release is available on:

Your semantic-release bot 📦🚀

@gajus gajus added the released label Nov 2, 2022
crapStone pushed a commit to Calciumdibromid/CaBr2 that referenced this issue Nov 10, 2022
This PR contains the following updates:

| Package | Type | Update | Change |
|---|---|---|---|
| [eslint-plugin-jsdoc](https://github.com/gajus/eslint-plugin-jsdoc) | devDependencies | patch | [`39.6.0` -> `39.6.2`](https://renovatebot.com/diffs/npm/eslint-plugin-jsdoc/39.6.0/39.6.2) |

---

### Release Notes

<details>
<summary>gajus/eslint-plugin-jsdoc</summary>

### [`v39.6.2`](https://github.com/gajus/eslint-plugin-jsdoc/releases/tag/v39.6.2)

[Compare Source](gajus/eslint-plugin-jsdoc@v39.6.1...v39.6.2)

##### Bug Fixes

-   update `jsdoccomment` ([26141cb](gajus/eslint-plugin-jsdoc@26141cb))

### [`v39.6.1`](https://github.com/gajus/eslint-plugin-jsdoc/releases/tag/v39.6.1)

[Compare Source](gajus/eslint-plugin-jsdoc@v39.6.0...v39.6.1)

##### Bug Fixes

-   **`no-restricted-syntax`:** update jsdoccomment to be able to use new `descriptionStartLine`, `descriptionEndLine`, and `hasPreterminalDescription` properties; fixes [#&#8203;830](gajus/eslint-plugin-jsdoc#830) ([d68d742](gajus/eslint-plugin-jsdoc@d68d742))

</details>

---

### Configuration

📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined).

🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied.

♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about this update again.

---

 - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box

---

This PR has been generated by [Renovate Bot](https://github.com/renovatebot/renovate).
<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNC4xMi4xIiwidXBkYXRlZEluVmVyIjoiMzQuMjEuMiJ9-->

Co-authored-by: cabr2-bot <[email protected]>
Reviewed-on: https://codeberg.org/Calciumdibromid/CaBr2/pulls/1625
Reviewed-by: Epsilon_02 <[email protected]>
Co-authored-by: Calciumdibromid Bot <[email protected]>
Co-committed-by: Calciumdibromid Bot <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants