4.0.0 β’ Published 6 months ago
@putout/plugin-remove-unused-private-fields v4.0.0
@putout/plugin-remove-unused-private-fields 
Class fields are public by default, but private class members can be created by using a hash
#prefix. The privacy encapsulation of these class features is enforced by JavaScript itself.(c) MDN
πPutout plugin adds ability to remove unused private fields.
Install
npm i @putout/plugin-remove-unused-private-fieldsRule
{
"rules": {
"remove-unused-private-fields": "on"
}
}β Incorrect code example
class Hello {
#a = 5;
#b = 3;
get() {
return this.#a;
}
}β Correct code Example
class Hello {
#a = 5;
get() {
return this.#a;
}
}Comparison
| Linter | Rule | Fix |
|---|---|---|
| π Putout | remove-unused-private-fields | β |
| β£ ESLint | no-unused-private-class-members | β |
License
MIT