Navigation

The Buildbot development team is primarily Python experts and not front-end experts.
Whlie we did spend lot of time looking for front end best practices, we are happy to accept suggestions to this coding-style and best-practices guide.

Here is a summary of what is the expected coding style for buildbot contributions, as well as some common gotcha's for developers with a Python background.

CoffeeScript does not have inlineCallbacks, but have some syntax sugar for helping readability of nested callbacks.
However, those syntax sugars sometimes leads to surprises.
Make sure you check the generated javascript in case of weird behavior.

Follow the following suggestions:

Use implicit parentheses for multi line function calls or object construction:

In CoffeeScript, "everything is an expression", and the default return value is the result of the last expression.
This is considered too error prone for Python and JS developers who are used to "return None" by default.
In buildbot code, every multiline function must end with an explicit return statement.

There is a very limited standard library in JS, and none in CoffeeScript.
However, de-facto general purpose libraries have emerged.

JQuery considered harmful to access the DOM directly.

Buildbot ships with JQuery, because it is supposed to be more optimized than AngularJS's own jqlite, and because some 3rd party directives are requiring it.
However, it must not be used in Buildbot services or controllers, and should be avoided in directives.
The Buildbot UI should follow AngularJS best practices and only modify DOM via templates.

Lodash is a clone of Underscore.js, and provides good utilities for standard types manipulation (array and objects).
Underscore-string is also available for string manipulation function (e.g. startsWith, endsWith )

Avoid using lodash decoration form.
Those are considered tricky to use.

# GOOD_.each(res,(a) ->a+1))# BAD_(res).each((a) ->a+1))

Require.js is used as technical solution for plugin loading.
It should not be used appart from this.

Moment.js is used for manipulating dates and displaying them to the user in a human readable form (e.g "one month ago").
It can be used anywhere it is useful.