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
Rule proposal: multiline-comment-style #8320
Comments
I could try to implement this, but I have absolutely no clue how to implement an autofixer for this. But I guess this can be also implemented later. |
I've already started working on an implementation for this. (Sorry, I should have mentioned that earlier.) |
This code is currently messy and incomplete. There are also some edge cases that the rule's design needs to address (e.g. allowing "banner" comments which are created from several consecutive line comments).
@not-an-aardvark Will this also enforce a space after |
Any eta for this? Doesn't seem to be merged to master yet, but would be very nice to have. |
Ping @not-an-aardvark, are you still working on this or can someone else take a crack at it? |
I'm not actively working on this right now, someone else can feel free to take it. I have a WIP commit here, so feel free to work from my partial implementation and test cases. I have a few minor usability concerns with the current design of the rule -- for example, it disallows "banner comments" like the one below, since they're just consecutive line comments: //------------------------------
// this is a banner comment
//------------------------------ But maybe we can address those after the initial implementation. |
What about use cases like this? // Same line, "flat"
/* this line
calls foo() */
// Same line, lining up the text
/* this line
calls foo() */
// Include newline, "flat"
/*
this line
calls foo()
*/
// Include newline, indented (to an arbitrary amount of spaces/tabs)
/*
this line
calls foo
*/ |
@lfp6 could you clarify your question? I'm not sure what you're asking about with regard to those examples. |
This code is currently messy and incomplete. There are also some edge cases that the rule's design needs to address (e.g. allowing "banner" comments which are created from several consecutive line comments).
This code is currently messy and incomplete. There are also some edge cases that the rule's design needs to address (e.g. allowing "banner" comments which are created from several consecutive line comments).
* New: multiline-comment-style rule (fixes #8320) This code is currently messy and incomplete. There are also some edge cases that the rule's design needs to address (e.g. allowing "banner" comments which are created from several consecutive line comments). * Chore: add multiline-comment-style in eslint:recommended. * finished :( * Fix: review suggestions Squashed commits: [914bea1] fix: fixer would cause invalid syntax. [a4dd76c] Fix: isJSDoc checking each line starts with "*". [e16985a] prefer fixer.replaceText(). . * Update multiline-comment-style.md
Please describe what the rule should do:
This rule enforces the styling of multiline comments. It has the following options:
separate-lines
disallows multiline block comments in favor of using consecutive line comments.starred-block
(default) disallows consecutive line comments in favor of using a block comment, and requires block somments to have a*
at the beginning of each line.bare-block
disallows consecutive line comments in favor of using a block comment, and prohibits block comments from having a*
at the beginning of each line.The rule always ignores configuration comments (using the same heuristic as the other existing comment rules). When using the
separate-lines
orbare-block
options, the rule ignores JSDoc comments.What category of rule is this? (place an "X" next to just one item)
[x] Enforces code style
[ ] Warns about a potential error
[ ] Suggests an alternate way of doing something
[ ] Other (please specify:)
Provide 2-3 code examples that this rule will warn about:
Why should this rule be included in ESLint (instead of a plugin)?
Comment styling is an extremely common stylistic concern. Many styleguides require a particular format for multiline comments, including
Since ESLint doesn't provide a rule to lint for comment style, it's difficult for project maintainers to automatically enforce a styleguide. Adding a rule for this would make it easier to use consistent formatting and to satisfy a very common styleguide requirement.
The text was updated successfully, but these errors were encountered: