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

spaced-comment: Clarify support for single line comments #13032

Closed
mijelin opened this issue Mar 11, 2020 · 1 comment · Fixed by #13126
Closed

spaced-comment: Clarify support for single line comments #13032

mijelin opened this issue Mar 11, 2020 · 1 comment · Fixed by #13126
Labels
accepted There is consensus among the team that this change meets the criteria for inclusion archived due to age This issue has been archived; please open a new issue for any further discussion documentation Relates to ESLint's documentation rule Relates to ESLint's core rules

Comments

@mijelin
Copy link

mijelin commented Mar 11, 2020

The version of ESLint you are using.

  • ESLint Version: 6.8.0
  • Node Version: 10.15.3
  • npm Version: 6.11.3

The problem you want to solve.
Update documentation and examples for spaced-comment rule.

The existing documentation includes examples such as the following:

/* eslint spaced-comment: ["error", "always", { "exceptions": ["*"] }] */

/****************
 * Comment block
 ****************/
/* eslint spaced-comment: ["error", "always", { "line": { "exceptions": ["-"] } }] */

//--------------
// Comment block
//--------------

However, it is not clear whether the rule supports something similar for single-line comments:

/////// UTILITIES

/***** Constants *****/

or why

/* eslint spaced-comment: ["error", "always", { "exceptions": ["*"] }] */

allows for

/***********
 * COMMENT *
 * *********/

but not

/***** COMMENT *****/

The only way I've found to allow for the single-line examples (I'm trying to apply this rule to an existing codebase) is to abuse the "marker" option:

"spaced-comment": [
  "error",
  "always",
  {
    // "exceptions": ["/", "*"] // this does not work
    markers: ["/////", "****"]  // this does work, but I have to specify the exact number of characters
  }
]

Your take on the correct solution to problem.
For single-line comments:

  • If this type of exception is already supported, add additional examples (similar to the above).
  • If this is intentionally not supported, make this clear.

If this is currently not supported, but something the team is willing to consider, then I'm happy to convert this to a rule change request. :)

Are you willing to submit a pull request to implement this change?
Yes, just not sure what the intended behavior is.

@mijelin mijelin added core Relates to ESLint's core APIs and features enhancement This change enhances an existing feature of ESLint triage An ESLint team member will look at this issue soon labels Mar 11, 2020
@mdjermanovic mdjermanovic added rule Relates to ESLint's core rules accepted There is consensus among the team that this change meets the criteria for inclusion documentation Relates to ESLint's documentation and removed core Relates to ESLint's core APIs and features enhancement This change enhances an existing feature of ESLint triage An ESLint team member will look at this issue soon labels Mar 11, 2020
@mdjermanovic
Copy link
Member

Hi @mijelin, thanks for the issue!

I can confirm this is the intended behavior. An exception should start from the beginning of the comment and repeat until the end of the line (or */ if it is on the same line):

/* eslint spaced-comment: ["error", "always", { "exceptions": ["-"] }] */

//----

/*----*/

/*----
*/

If this is intentionally not supported, make this clear.

Completely agree, a PR to clarify "exceptions" in the documentation is welcome!

If this is currently not supported, but something the team is willing to consider, then I'm happy to convert this to a rule change request. :)

This would need an additional option, so I think it's good to have two separate issues in this case - one to improve the documentation for the actual behavior, the other to evaluate an enhancement.

Since this one already has a title and form of a documentation issue, I marked it as accepted. Feel free to open another issue for a rule change request :)

kaicataldo pushed a commit that referenced this issue Apr 4, 2020
* Docs: update exception details to cover newline issue (fixes #13032)

* Docs: refactore explaination and added example

* chore: changed explaination

* Chore: change from 'line' to 'block' docs eg
@eslint-deprecated eslint-deprecated bot locked and limited conversation to collaborators Oct 2, 2020
@eslint-deprecated eslint-deprecated bot added the archived due to age This issue has been archived; please open a new issue for any further discussion label Oct 2, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
accepted There is consensus among the team that this change meets the criteria for inclusion archived due to age This issue has been archived; please open a new issue for any further discussion documentation Relates to ESLint's documentation rule Relates to ESLint's core rules
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants