Thursday, March 22, 2012

Styleguide - JavaScript

Styleguide - JavaScript: "0. Overview
1. Behaviors
2. Events
JavaScript Styleguide
To be fleshed out.

Coding Style

Write new JS in CoffeeScript.
Use soft-tabs with a two space indent.
Always use camelCase, never underscores.
Use implicit parentheses when possible.
Follow @jashkenas's style. See the documentation for good examples.
Any top level objects should be namespaced under the GitHub namespace.
Don't ever use $.get or $.post. Instead use $.ajax and provide both a success handler and an error handler.
Use $.fn.on instead of $.fn.bind, $.fn.delegate and $
Existing JavaScript

Avoid adding new .js files.
Use soft-tabs with a two space indent.
Do your best to never use a semicolon. This means avoiding them at line breaks and avoiding multi-statement lines. For more info, read Mislav's blog post."

'via Blog this'