-
Notifications
You must be signed in to change notification settings - Fork 334
EpicEditor Code Style Guide
##General
We use soft-tabs (spaces) and two of them.
##JavaScript
###Semicolons
Everywhere JSHint says. No exceptions.
###Whitespace
We like spaces and whitespace. This means blocks always go on new lines and spaces between paramater names, ()
after function declarations and even Math
symbols. Please note all the white space below.
function foo (bar, baz) {
var x = 1;
if (x === 1) {
x = (x + 1) * 3;
}
}
###Conditionals
Each conditional block goes on a new line. See below:
if (foo) {
}
else if () {
}
else {
}
###Functions
All public methods should chain to the prototype
. We try to eat our own dog food (or so they say) where we can. If something would be useful for a developer we make it public and put it on the prototype
. Otherwise we make it a private function. We use underscores to denote privates.
//Private
function _foo () {
return 'bar';
}
//Public
hello.prototype.world = function () {
return _foo();
}
####Defaults
When setting defaults use the bar = bar || 'default'
syntax when you can.
function foo (bar) {
bar = bar || 'default';
return bar
}
###Variables
We set only one var
per functional scope and we use comma first when writing multiple var
s.
function foo () {
var a = 1
, b = 2;
return a + b;
}
##CSS
STILL IN PROGRESS
Since we compress all the CSS, we write all CSS in the themes like so:
selector {
property: value;
}
Use shorthand where you can aside from font
. No one ever remembers the syntax for font
, but margin
, padding
, border
, and all others should use shorthand in cases where you are not overriding specific styles.
Always put semicolons in.