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

Feature request: rule to enforce asterisks #199

Closed
c-vetter opened this issue Apr 12, 2019 · 13 comments · Fixed by #446 or #730
Closed

Feature request: rule to enforce asterisks #199

c-vetter opened this issue Apr 12, 2019 · 13 comments · Fixed by #446 or #730

Comments

@c-vetter
Copy link
Contributor

It would be nice to have a rule that enforces every line in a JSdoc comment to start with an asterisk, as in https://palantir.github.io/tslint/rules/jsdoc-format/

@golopot
Copy link
Collaborator

golopot commented Jun 23, 2019

Comparison between tslint/jsdoc-format and eslint-plugin-jsdoc:

  • each line contains an asterisk - jsdoc/require-asterisk-prefix (Brett editing post to check off)
  • asterisks must be aligned - jsdoc/check-alignment
  • disallow extra space after asterisks - jsdoc/check-indentation
  • require newline after main description - jsdoc/newline-after-description
  • require one space after asterisks - jsdoc/check-line-alignment
  • bare block comment: disallow asterisks (Is this a reference to "one line comments must start with /** and end with */"?); if so, I think this could be merged with item below not to allow any multiple asterisks (Brett editing post to add)
  • multiline comments don’t allow text after /** in the first line (under option) Multiline blocks #733
  • [ ] the only characters before the asterisk on each line must be whitespace characters - seems it would be hard to distinguish from asterisks intended within descriptions (Brett editing post to add)

Both unsupported:

skeggse pushed a commit to skeggse/eslint-plugin-jsdoc that referenced this issue Dec 14, 2019
This rule checks that each line of the jsdoc comment starts with an asterisk. For composability with
other rules, this does not check the alignment or indentation of the comment content.

fix gajus#199
skeggse pushed a commit to skeggse/eslint-plugin-jsdoc that referenced this issue Dec 14, 2019
This rule checks that each line of the jsdoc comment starts with an asterisk. For composability with
other rules, this does not check the alignment or indentation of the comment content.

fix gajus#199
@skeggse
Copy link
Contributor

skeggse commented Dec 14, 2019

I submitted a PR for this at #446. Not amazingly happy about the name, though - thoughts?

skeggse pushed a commit to skeggse/eslint-plugin-jsdoc that referenced this issue Dec 14, 2019
This rule checks that each line of the jsdoc comment starts with an asterisk. For composability with
other rules, this does not check the alignment or indentation of the comment content.

fix gajus#199
@brettz9
Copy link
Collaborator

brettz9 commented Jan 11, 2020

Other checks I can think of on this general topic might be:

  1. Avoiding multiple asterisks (beyond the obligatory first two), whether at the beginning, end, or middle
  2. Avoiding single line jsdoc blocks such as /** @param abc */, perhaps excepting some tags like @lends which, um, "lend" themselves to single line expressions because of their terseness.

brettz9 pushed a commit to skeggse/eslint-plugin-jsdoc that referenced this issue Jan 29, 2021
This rule checks that each line of the jsdoc comment starts with an asterisk. For composability with
other rules, this does not check the alignment or indentation of the comment content.

fix gajus#199
brettz9 pushed a commit to brettz9/eslint-plugin-jsdoc that referenced this issue Jan 31, 2021
This rule checks that each line of the jsdoc comment starts with an asterisk. For composability with
other rules, this does not check the alignment or indentation of the comment content.

fix gajus#199
brettz9 pushed a commit to brettz9/eslint-plugin-jsdoc that referenced this issue May 8, 2021
This rule checks that each line of the jsdoc comment starts with an asterisk. For composability with
other rules, this does not check the alignment or indentation of the comment content.

fix gajus#199
brettz9 pushed a commit to brettz9/eslint-plugin-jsdoc that referenced this issue May 9, 2021
This rule checks that each line of the jsdoc comment starts with an asterisk. For composability with
other rules, this does not check the alignment or indentation of the comment content.

fix gajus#199
brettz9 added a commit that referenced this issue May 10, 2021
feat: add require-asterisk-prefix rule; fixes #199

This rule checks that each line of the jsdoc comment starts with an asterisk. For composability with other rules, this does not check the alignment or indentation of the comment content. Allow any/never/always option and `tags` option.

Co-authored-by: Eli Skeggs <eli@mixmax.com>
Co-authored-by: Brett Zamir <brettz9@yahoo.com>
@gajus
Copy link
Owner

gajus commented May 10, 2021

🎉 This issue has been resolved in version 33.2.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

@gajus gajus added the released label May 10, 2021
@brettz9 brettz9 reopened this May 10, 2021
@brettz9
Copy link
Collaborator

brettz9 commented May 10, 2021

I've turned @golopot 's comment into a kind of wiki-style comment, adding my own items (though marked as being added by me), so we could track the items for this issue all in one place. The require/forbid asterisk rule has been added/released, but not these other items.

@brettz9
Copy link
Collaborator

brettz9 commented May 12, 2021

Regarding reporting jsdoc blocks with multiple asterisks at the beginning, I've just pushed a fix at 28397c7 so that no-bad-blocks can also check 3+ asterisks when what appears to be a tag is found therein. That case is being handled separately because multiple asterisks at the beginning are not actually jsdoc (so we use that rule to catch comments which look like jsdoc).

I've also filed #728 so as to allow preventing /*** ... */ in that rule even where the contents appear to have no tag (normally not prevented since it could just be a multiline comment with a lot of asterisks).

@brettz9
Copy link
Collaborator

brettz9 commented May 13, 2021

After the current PRs, I think the one remaining item here would belong in a rule like multiline-comments with options;

  1. No line 0 text if multiline
  2. Avoid single line entirely, unless optionally possessing specific tags like @lends
  3. Require single lines only, optionally if under a certain length and/or if tags and/or particular tags are present

@brettz9
Copy link
Collaborator

brettz9 commented May 14, 2021

After the current PRs, I think the one remaining item here would belong in a rule like multiline-comments with options;

1. No line 0 text if multiline

2. Avoid single line entirely, unless optionally possessing specific tags like `@lends`

3. Require single lines only, optionally if under a certain length and/or if tags and/or particular tags are present

Btw, @golopot , it'd be great to have your feedback in before I prepare the PRs. Thanks...

@gajus
Copy link
Owner

gajus commented May 15, 2021

🎉 This issue has been resolved in version 34.6.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

@danvk
Copy link

danvk commented May 16, 2021

I'm not sure whether tslint enforced this, but another asterisk-related formatting issue I sometimes see is not putting the trailing */ on its own line in a multiline block.

For example, rather than writing it like this:

/**
 * This is a multline
 * jsdoc comment */

the more canonical way to write it is like this:

/**
 * This is a multline
 * jsdoc comment
 */

It looks like no-multi-asterisks is in the ballpark, but doesn't quite enforce this.

@brettz9
Copy link
Collaborator

brettz9 commented May 16, 2021

Please file as a new issue. Thanks!

@brettz9
Copy link
Collaborator

brettz9 commented May 16, 2021

And, btw, I think it would be fine as a new option under multiline-blocks given the rule's already handling single line blocks).

@danvk
Copy link

danvk commented May 16, 2021

@brettz9 sure, filed #738

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
6 participants