-
Notifications
You must be signed in to change notification settings - Fork 55
FOAM2 Style Guidelines
Kevin Glen Roy Greer edited this page Apr 8, 2016
·
1 revision
Except where noted below, FOAM conforms to the jQuery JavaScript Style Guide available at:
https://contribute.jquery.org/style-guide/js/
- Indentation is two spaces rather than one tab.
- The ! operator is followed by a space.
if ( ! found ) ...- One-statement if, while, and for statements that fit in less than 80 characters, do not need braces.
if ( ! found ) return false;
for ( var i = 0 ; i < a.length ; i++ ) a[i] = '';- jQuery type checks don't apply.
- Model names should be capitalized CamelCase. Ex.
Model,Photo,EMail. - Acronyms should have all letters capitalized: Ex.
DAO - Properties should start with a lower-case character and be camelCase. Ex.
parent,firstName - Non-public properties and methods can end with an underscore (
_). Ex.listeners_ - Use
NAMES_LIKE_THISfor constant values.
Code should be modeled rather than created as conventional JS prototypes.
Provide property labels when the default labelization of the property name will not be helpful or attractive to users.
Line lengths should be 80 characters or less, except for embedded data, like templates or sprites, or when modifying the code to make it fit in less than 80 characters would actually makes it less readable.
- Do not quote map keys unless necessary.
- Do not leave trailing unnecessary commas.
TODO