mirror of
https://github.com/electron/electron.git
synced 2026-01-25 23:38:18 -05:00
Merge pull request #5073 from electron/naming-things
Document API naming conventions
This commit is contained in:
@@ -39,9 +39,16 @@ etc.
|
||||
* [Template literals](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Template_literals)
|
||||
instead of string concatenation using `+`
|
||||
|
||||
## API Names
|
||||
## Naming Things
|
||||
|
||||
When creating a new API, we should prefer getters and setters instead of
|
||||
Electron APIs uses the same capitalization scheme as Node.js:
|
||||
|
||||
- When the module itself is a class like `BrowserWindow`, use `CamelCase`.
|
||||
- When the module is a set of APIs, like `globalShortcut`, use `mixedCase`.
|
||||
- When the API is a property of object, and it is complex enough to be in a separate chapter like `win.webContents`, use `mixedCase`.
|
||||
- For other non-module APIs, use natural titles, like `<webview> Tag` or `Process Object`.
|
||||
|
||||
When creating a new API, it is preferred to use getters and setters instead of
|
||||
jQuery's one-function style. For example, `.getText()` and `.setText(text)`
|
||||
are preferred to `.text([text])`. There is a
|
||||
[discussion](https://github.com/electron/electron/issues/46) on this.
|
||||
|
||||
Reference in New Issue
Block a user