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
[explicit-member-accessibility] False positive when using private fields #1666
Comments
We do not yet support 3.8 syntax, including private fields. |
@bradzacher Wouldn't it be possible to simply ignore properties starting with |
No. The AST for private names is different, and thus the The AST is not yet finalised either, so we cannot build a rule on top of it. |
This statement seems to be incorrect. The I've just checked that and this small change fixed the problem:
by
|
To clarify - this will work right now due to "dumb luck" of sorts. However - this isn't entirely correct. The name of the member is class Test {
#foo: string = 'a';
'#foo': string = 'b';
test() {
console.log(this.#foo, this['#foo']);
}
}
For both of these cases, however, |
Do we have any updates on this issue? |
Any updates? |
Is there a rough estimation when this could be fixed? |
I believe majority of projects don't use leading dash and quotes around class properties and even they do, now they have a problem because leading dash means a private class property in js. Even if js doesn't throw an error for this syntax, it will be confusing for developers. So, I don't understand why all the rest should struggle to use new private class properties just for the sake of rule to be 100% complete (even though it's not 100% complete now, if we take into consideration private properties) |
Adding exact search term here because I stumbled over this issue, too:
|
Aha, I believe this was fixed by #3808. Please post back if that's incorrect and I can reopen! 🚀 |
I've just updated to
Do I need to do something to make this work? |
@OldStarchy could you please post a full reproduction so that I can take a look? With just your versions and a single error there's nothing I can help with. |
I'm getting Test case: |
@jramstedt, friend, fellow, internet person, please post a full reproduction including your package versions. We can't help you if you just post a couple of snippets. |
Here are the versions.
Do you have all the needed info to reproduce it? |
looks like it was implemented for methods typescript-eslint/packages/eslint-plugin/src/rules/explicit-member-accessibility.ts Lines 113 to 118 in 4875cd6
But not for properties typescript-eslint/packages/eslint-plugin/src/rules/explicit-member-accessibility.ts Lines 212 to 223 in 4875cd6
|
Repro
The rule
@typescript-eslint/explicit-member-accessibility
reports a false positive when using private fields. At the same time, TypeScript reports the errorAn accessibility modifier cannot be used with a private identifier
if an accessibility modifier would be used.Expected Result
No false positive when using private fields.
Actual Result
Additional Info
Versions
@typescript-eslint/eslint-plugin
2.22.0
@typescript-eslint/parser
2.22.0
TypeScript
3.8.3
ESLint
6.8.0
node
12.16.1
npm
6.14.1
The text was updated successfully, but these errors were encountered: