-
Notifications
You must be signed in to change notification settings - Fork 8.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Vote: underscores on variables to indicate privateness #13324
Comments
I think we should add an exception and encourage this pattern because:
|
Can someone provide some concrete examples of using this pattern effectively? I'm on the fence and am leaning towards just allowing it if others find it valuable, but would love to talk about this more with examples. |
Regarding TS: when/if we migrate to TS, it will be easier to mark every underscore-prefixed method/property as |
Really good point @azasypkin. I think I'll switch my vote given that benefit. Thanks for highlighting it! |
The same is true once we have private fields in ecmascript, where we can change the |
@chrisronline Perhaps the example that spurred this discussion is a decent one: https://github.com/spalger/kibana/blob/0d4e7e37ddf4e8871fabb24d14f0ff0d449e30f1/test/functional/services/test_subjects.js#L102 In that scenario, the This is a very simple example, but it's focused on the reason that one might want methods that are actually methods, but not a part of the "public" API |
Parts of our codebase contain variables or functions named with a preceding underscore to indicate they should not be accessed externally.
e.g.:
The airbnb style guide (which we never officially switched to, but unofficially lean towards) discourages this practice: https://github.com/airbnb/javascript#naming--leading-underscore
I personally don't think it will be needed once we switch to typescript which has the private keyword, but don't feel too strongly either way. I would however like to come to a consensus on this, I notice some team members use it consistently where other (like myself) don't use it at all.
cc @spalger
Thumbs up this issue if you wish to add an exception to our own style guide to continue the practice of using underscores. Thumbs down this issue if you wish to abide by the airbnb style guide and stop using underscores to indicate privateness
The text was updated successfully, but these errors were encountered: