From 193c6d6e93dc09050e46521ab5e7ca6622c2e465 Mon Sep 17 00:00:00 2001 From: Zeke Sikelianos Date: Thu, 7 Apr 2016 09:40:31 -0700 Subject: [PATCH] :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.