This repository was archived by the owner on Jan 13, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
coding standards
oatkiller edited this page Sep 13, 2010
·
1 revision
- Name your vars like_this not likeThis.
- unless its an exact copy of a JavaScript 1.6+ method from MDC or something else like that and that fn is named differently
Use 1TBS http://en.wikipedia.org/wiki/Indent_style#Variant:_1TBS
maximum consecutive new line chars is 1
put each function in a file of its own when possible. name the file the same thing as the method in it
Try and use var as little as makes sense. Saves bytes an makes you think over what you’re doing. i think?
- don’t use named function declarations. http://yura.thinkweb2.com/named-function-expressions/
- declare all functions like this
// leave a space between the identifier 'function' and the following paren.
// leave a space between the ) and the {
var my_fn = function () { ... };
- when you execute functions, don’t leave a space between the fn identifier and the first (
- don’t put spaces between params or commas
- you can use line breaks and tabs tho
// like this
my_fn(1,2,3);
// not this
my_fn(1, 2, 3);
- put a space on either side of any infix operators except . (i think.)
i like to use " for attributes in markup
always use ;