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

Formatting rule for disable directive spacing #14878

Closed
TSMMark opened this issue Aug 4, 2021 · 6 comments
Closed

Formatting rule for disable directive spacing #14878

TSMMark opened this issue Aug 4, 2021 · 6 comments
Labels
archived due to age This issue has been archived; please open a new issue for any further discussion autofix This change is related to ESLint's autofixing capabilities core Relates to ESLint's core APIs and features enhancement This change enhances an existing feature of ESLint
Projects

Comments

@TSMMark
Copy link

TSMMark commented Aug 4, 2021

Please describe what the rule should do:

warn about (and ideally fix) spacing in eslint-disable and eslint-enable comments.

What category of rule is this? (place an "X" next to just one item)

[ ] Warns about a potential error (problem)
[X] Suggests an alternate way of doing something (suggestion)
[ ] Other (please specify:)

Provide 2-3 code examples that this rule will warn about:

Bad:

/* eslint-disable   some-rule */
/* eslint-enable   some-rule */
/* eslint-disable some-rule,   other-rule    */
//    eslint-disable-next-line   some-rule,   other-rule
// eslint-disable-line   some-rule   ,   other-rule

Good:

/* eslint-disable some-rule */
/* eslint-enable some-rule */
/* eslint-disable some-rule, other-rule */
// eslint-disable-next-line some-rule, other-rule */
// eslint-disable-line some-rule, other-rule */

Why should this rule be included in ESLint (instead of a plugin)?

#14617 introduces fixable disable directives, which have the potential to be formatted with awkward spacing, so @mdjermanovic recommended opening this new issue

Are you willing to submit a pull request to implement this rule?

Potentially

@TSMMark TSMMark added feature This change adds a new feature to ESLint rule Relates to ESLint's core rules triage An ESLint team member will look at this issue soon labels Aug 4, 2021
@eslint-github-bot eslint-github-bot bot added this to Needs Triage in Triage Aug 4, 2021
@nzakas
Copy link
Member

nzakas commented Aug 5, 2021

I’m not in favor of this. With nearly 300 rules in the core already, I don’t think this rises to the level needed for inclusion.

You can always create a custom rule to do this if it’s important to you.

@nzakas nzakas removed the triage An ESLint team member will look at this issue soon label Aug 5, 2021
@nzakas nzakas moved this from Needs Triage to Feedback Needed in Triage Aug 5, 2021
@bmish
Copy link
Sponsor Member

bmish commented Aug 5, 2021

eslint-plugin-eslint-comments could be a good place for such a rule.

@mdjermanovic
Copy link
Member

@TSMMark thanks for opening the issue! I don't think we should add a core rule for this (plugin is a good idea though). My comment #14617 (comment) was about updating the autofix we implemented in #14617 to better handle the leading space if it doesn't end up being too complex.

@nzakas
Copy link
Member

nzakas commented Aug 10, 2021

I’m 👍 to trying to produce a better autofix

@nzakas nzakas added autofix This change is related to ESLint's autofixing capabilities core Relates to ESLint's core APIs and features enhancement This change enhances an existing feature of ESLint and removed rule Relates to ESLint's core rules feature This change adds a new feature to ESLint labels Aug 10, 2021
@mdjermanovic
Copy link
Member

#14617 introduces fixable disable directives, which have the potential to be formatted with awkward spacing

I'm working on #14617 (comment)

@mdjermanovic
Copy link
Member

I'm closing this issue since it isn't likely that the proposed rule will be accepted.

Fix for #14617 (comment) is included in the recent ESLint v8.0.0-rc.0 release.

@TSMMark thanks for testing new features on your codebase! Please let us know if you encounter any issues with the new version of this autofix.

Triage automation moved this from Feedback Needed to Complete Sep 28, 2021
@eslint-github-bot eslint-github-bot bot locked and limited conversation to collaborators Mar 28, 2022
@eslint-github-bot eslint-github-bot bot added the archived due to age This issue has been archived; please open a new issue for any further discussion label Mar 28, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
archived due to age This issue has been archived; please open a new issue for any further discussion autofix This change is related to ESLint's autofixing capabilities core Relates to ESLint's core APIs and features enhancement This change enhances an existing feature of ESLint
Projects
Archived in project
Triage
Complete
Development

No branches or pull requests

4 participants