sindresorhus/eslint-plugin-unicorn
Rule proposal: `prefer-private-class-fields`
クローズ
#979 opened on 2021/01/01
help wantednew rule
Repository metrics
- Stars
- (5,022 個のスター)
- PR merge metrics
- (平均マージ 4h 30m) (30d で 26 merged PRs)
説明
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'
}
}