Skip to content

Style Guide

JB codecorsair edited this page Jul 29, 2016 · 4 revisions

TypeScript

We mostly follow the AirBnb JavaScript style guide. I'll be fully writing up everything eventually for our own. For now, I'll write down some deviations for our source from AirBnb.

WhiteSpace

  • Braces

    Do not put a space between curly braces when using object destructuring, or inline declarations of objects.

    // good
    import {client} from 'camelot-unchained';
    // bad
    import { client } from 'camelot-unchained';

Functions

  • Declaration

    Use an expression for member functions.

    // good
    class foo {
      public sayHello = () => { console.log('Hello'); }
    }
    
    // bad
    class foo {
      public sayHello() { console.log('Hello'); }
    }
    

    Use a named function declaration outside of class scope.

    // good
    function sayHello() { console.log('Hello'); }
    
    // bad
    const sayHello = () => console.log('Hello');
    
Clone this wiki locally