mirror of
https://github.com/elastic/kibana.git
synced 2025-04-23 17:28:26 -04:00
Update JS style guide with rule for prefixing private class methods with an underscore. (#20851)
This commit is contained in:
parent
bea8bb4dda
commit
1a65b3577a
1 changed files with 14 additions and 0 deletions
|
@ -215,6 +215,20 @@ class bank_account {}
|
|||
class bankAccount {}
|
||||
```
|
||||
|
||||
## Prefix private class methods with an underscore
|
||||
|
||||
Identifying private class methods makes it easier to differentiate a class's public and internal
|
||||
APIs, and makes private methods easier to mark as `private` when the code is migrated to TypeScript.
|
||||
|
||||
```js
|
||||
// good
|
||||
class BankAccount {
|
||||
addFunds() {}
|
||||
|
||||
_calculateInterest() {}
|
||||
}
|
||||
```
|
||||
|
||||
## Magic numbers/strings
|
||||
|
||||
These are numbers (or other values) simply used in line in your code. *Do not
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue