-
-
Notifications
You must be signed in to change notification settings - Fork 404
Rule proposal: prefer-private-class-fields
#979
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
Comments
This is now accepted. But it's blocked by:
|
I've already tried to implement this the other day, my experience on using private fields, I really need proposal-destructuring-private const {a, b, c, d} = this
const e = this.#e awkward! |
@fisker I would argue having to use a |
One thing to consider is that |
i have also had to do: const a = this.#a
const b = this.#b
const c = this.#c And I agree that it feels a bit awkward and inconvenient. but not something that's bothering me that much. const {a, b, c} = this.#bag || { } i rather prefer |
{
'no-restricted-syntax': [
'error',
{
selector: ':matches(PropertyDefinition, MethodDefinition)[accessibility="private"]',
message: 'Use #private instead',
},
],
} |
Uh oh!
There was an error while loading. Please reload this page.
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Classes/Private_class_fields
Prefer private fields over the convention of underscore prefixed names.
This feature requires Node.js 12, so we cannot add it to the recommended preset until April 2021 (date of Node.js 10 obsoletion).
Does ESLint support this feature yet?
Fail
Pass
The text was updated successfully, but these errors were encountered: