Skip to content

Latest commit

 

History

History
48 lines (36 loc) · 1.31 KB

StyleGuide.md

File metadata and controls

48 lines (36 loc) · 1.31 KB

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.

Types

  • 1.a Implicit Any: Do not use an implicit any. If you are going to use the any type, explicitly declare it as such.
    // bad
    var items: any[] = items();
    items.map(i => console.log(i));
    
    // good
    var items: any[] = items();
    items.map((i: any) => console.log(i));

WhiteSpace

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

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

Functions

  • 3.a Function Expressions Use an expression for member functions. Use a named function declaration outside of class scope.

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