sindresorhus/eslint-plugin-unicorn
Rule proposal: `prefer-private-class-fields`
Closed
#979 opened on Jan 1, 2021
help wantednew rule
Repository metrics
- Stars
- (5,022 stars)
- PR merge metrics
- (Avg merge 1d 16h) (399 merged PRs in 30d)
Description
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
class Foo {
static _PRIVATE_STATIC_FIELD
_privateField
_privateMethod() {
return 'hello world'
}
}
Pass
class Foo {
static #PRIVATE_STATIC_FIELD
#privateField
#privateMethod() {
return 'hello world'
}
}