Description
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.