Make _classMembers 'private' using symbols
npm i mdwagner/babel-plugin-private-underscores-const -D
yarn add mdwagner/babel-plugin-private-underscores-const -D
Input
class Foo {
constructor() {
this._method();
}
_method() {
// ...
}
}
Output
const _method = Symbol('_method');
class Foo {
constructor() {
this[_method]();
}
[_method]() {
// ...
}
}
{
"plugins": [
"private-underscores-const"
]
}
Note: This is not real private, it just makes it a lot harder for people to accidentally use methods with underscores.