Javascript code standard
To ensure consistency throughout the source code, keep these rules in mind as you are working:
All features or bug fixes must be tested by one or more specs. We write our server-side test suite with mocha
and client-side test suite with karma.
All public API methods must be documented with ngdoc, an extended version of jsdoc (we added support for
markdown and templating via @ngdoc tag). To see how we document our APIs, please check out the existing
ngdoc and the ngdoc wiki
With the exceptions listed below, we follow the rules contained in Idiomatic JavaScript:
Wrap all code at 100 characters.
We’re not using comma first convention.
We use whitespace rule in section 2.D instead of 2.A, which means we don’t put extra spaces inside of
parentheses.
Instead of complex inheritance hierarchies, we prefer simple objects. We use prototypical inheritance only
when absolutely necessary.
We love functions and closures and, whenever possible, prefer them over objects.
To write concise code that can be better minified, internally we use aliases that map to the external API.
We don’t go crazy with type annotations for private internal APIs unless it’s an internal API that is used
throughout the project. The best guidance is to do what makes the most sense.