Conventions Client API Server API Architecture Getting Started

Coding Conventions

The source for the sapphire framework uses the following coding conventions. Any pull requests against the repository must meet these. An eslint configuration file for these conventions will be linked to below. Because the generated boilerplate using the Sapphire Command Line Interface also follows these conventions, it is recommended that Sapphire applications do so as well. The following are the big ones.


All code in Sapphire uses tabs rather than spaces. This way, if one coder likes two spaces and another likes four, they can setup their editor to show that many spaces for a tab.


Code written in Sapphire uses the Allman style of code indentation. This style puts the brace associated with a control statement on the next line, indented to the same level as the control statement. Statements within the braces are indented to the next level. It is not necessary for object literals to follow this same conventions, even though they also use braces. Also, single line statements without braces are allowed in this style, especially in cases that make the code more clear.

For example:

while (x == y)


if (x === null) return false;

var myObject = {
    a: 1,
    b: 'string',

Trailing Commas

The advantage of trailing commas is that when adding new items to an object or array, it isn't necessary to modify the line prior. This also makes it easy to move items around.


All strings in Sapphire should use single quotes.

The complete set of options from eslint.

File here: .eslintrc.js

module.exports = {
    rules: {
        'comma-dangle': [1, 'always-multiline'],
        'no-cond-assign': [1, 'always'],
        'no-dupe-args': 1,
        'no-dupe-keys': 1,
        'no-duplicate-case': 1,
        'no-empty': 1,
        'no-ex-assign': 1,
        'no-extra-boolean-cast': 1,
        'no-extra-semi': 1,
        'no-func-assign': 1,
        'no-inner-declarations': [1, 'functions'],
        'no-invalid-regexp': 1,
        'no-irregular-whitespace': 1,
        'no-unexpected-multiline': 1,
        'no-unreachable' : 1,
        'use-isnan': 1,
        'curly': 0,
        'default-case': 1,
        'no-extend-native': 0,
        'no-extra-bind': 0,
        'no-eval': 1,
        'no-implied-eval': 1,
        'no-invalid-this': 1,
        'no-labels': 1,
        'no-lone-blocks': 1,
        'no-new': 0,
        'no-redeclare': 1,
        'no-delete-var': 1,
        'no-shadow': 1,
        'no-use-before-define': 1,
        'brace-style': [1, 'allman', {allowSingleLine: true}],
        'camelcase': 1,
        'comma-spacing': [1, {before: false, after: true}],
        'indent': [1, 'tab', {SwitchCase: 1}],
        'linebreak-style': [1, 'unix'],
        'new-parens': 1,
        'no-mixed-spaces-and-tabs': [1, 'smart-tabs'],
        'semi': [1, 'always'],
        'quotes' : [1, 'single'],