From 193c6d6e93dc09050e46521ab5e7ca6622c2e465 Mon Sep 17 00:00:00 2001 From: Zeke Sikelianos Date: Thu, 7 Apr 2016 09:40:31 -0700 Subject: [PATCH 1/3] :memo: document API naming conventions --- docs/development/coding-style.md | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/docs/development/coding-style.md b/docs/development/coding-style.md index 52ae3c299a5b..ca517486218a 100644 --- a/docs/development/coding-style.md +++ b/docs/development/coding-style.md @@ -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 `clipboard`, 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 ` 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. From 4d8d4d5f2ac74a9ad3d3853c7fee3fe059c16e24 Mon Sep 17 00:00:00 2001 From: Zeke Sikelianos Date: Thu, 7 Apr 2016 09:49:17 -0700 Subject: [PATCH 2/3] use globalShortcut as a better mixedCase example --- docs/development/coding-style.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/development/coding-style.md b/docs/development/coding-style.md index ca517486218a..c08efa42ca68 100644 --- a/docs/development/coding-style.md +++ b/docs/development/coding-style.md @@ -44,7 +44,7 @@ etc. 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 `clipboard`, use mixedCase. +- 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 ` Tag` or `Process Object`. From 348a0e958bfeaa56633ddf6005a6f5d0524d48bf Mon Sep 17 00:00:00 2001 From: Zeke Sikelianos Date: Thu, 7 Apr 2016 09:49:55 -0700 Subject: [PATCH 3/3] wrap cases in backticks --- docs/development/coding-style.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/development/coding-style.md b/docs/development/coding-style.md index c08efa42ca68..baf2a2cce7de 100644 --- a/docs/development/coding-style.md +++ b/docs/development/coding-style.md @@ -43,9 +43,9 @@ etc. 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. +- 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 ` Tag` or `Process Object`. When creating a new API, it is preferred to use getters and setters instead of