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

allowAfterThisConstructor for no-underscore-dangle #11488

Closed
Labels
archived due to age This issue has been archived; please open a new issue for any further discussion auto closed The bot closed this issue enhancement This change enhances an existing feature of ESLint evaluating The team will evaluate this issue to decide whether it meets the criteria for inclusion rule Relates to ESLint's core rules

Comments

@sripberger
Copy link
Contributor

sripberger commented Mar 7, 2019

Like many, I've been using the no-underscore-dangle method to enforce the style of prefixing "private" members with underscores. It's nice in that it flags anytime such properties are accessed, and the allowAfterThis and allowAfterSuper rules make possible to work with these properties inside a class.

I have found an additional case that would be nice to allow: when an instance method or constructor wants to invoke a "private" static method. To make this possible without having to disable the rule on a case-by-case basis, I'd like to add an option to allow underscore dangles when referencing properties on this.constructor.

What rule do you want to change?

no-underscore-dangle

Does this change cause the rule to produce more or fewer warnings?

Fewer, optionally.

How will the change be implemented? (New option, new default behavior, etc.)?

New option.

Please provide some example code that this change will affect:

var a = this.constructor.foo_;
this.constructor._bar();

What does the rule currently do for this code?

Produces the following warnings/errors:
Unexpected dangling '_' in 'foo_' Unexpected dangling '_' in '_bar'

What will the rule do after it's changed?
Allows suppression in this case, if new allowAfterThisConstructor option is set to true.

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

Yes, will be creating it shortly.

@sripberger sripberger added enhancement This change enhances an existing feature of ESLint rule Relates to ESLint's core rules triage An ESLint team member will look at this issue soon labels Mar 7, 2019
@sripberger sripberger changed the title allowAfterConstructor for no-underscore-dangle allowAfterThisConstructor for no-underscore-dangle Mar 8, 2019
@platinumazure
Copy link
Member

Seems reasonable to me. I'll support this. 👍

@platinumazure platinumazure added evaluating The team will evaluate this issue to decide whether it meets the criteria for inclusion and removed triage An ESLint team member will look at this issue soon labels Mar 8, 2019
@eslint-deprecated eslint-deprecated bot added the auto closed The bot closed this issue label Apr 8, 2019
@eslint-deprecated
Copy link

Unfortunately, it looks like there wasn't enough interest from the team
or community to implement this change. While we wish we'd be able to
accommodate everyone's requests, we do need to prioritize. We've found
that issues failing to reach accepted status after 21 days tend to
never be accepted, and as such, we close those issues.
This doesn't mean the idea isn't interesting or useful, just that it's
not something the team can commit to.

Thanks for contributing to ESLint and we appreciate your understanding.

@eslint-deprecated eslint-deprecated bot locked and limited conversation to collaborators Oct 6, 2019
@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 6, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.