Skip to content

Latest commit

 

History

History
187 lines (144 loc) · 2.42 KB

CODE-STYLE.md

File metadata and controls

187 lines (144 loc) · 2.42 KB

Code Style

File Naming standards

The type of file is put at the end, it's fancySelectView not viewFancySelect and it's environmentController not controllerEnvironment. File names are camel cased, no dashes or underscores.

Javascript

var is only used to define one var, no multiline statements.

GOOD

var foo;
var bar;
var baz;

BAD

var foo,
  bar,
  baz;

Leading commas are avoided, we use trailing commas. Also make sure we don't have a dangling comma on the last item.

GOOD

var foo = [
  'foo',
  'bar',
  'baz'
]

BAD

var foo = [
  'foo'
  , 'bar'
  , 'baz'
]

Leading . on chains are expected:

GOOD

  promisify($scope.dir, 'destroy')()
    .catch(function () {
      console.log('foo');
    })
    .finally(function(){
      console.log('foo');
    });

BAD

  promisify($scope.dir, 'destroy')().catch(function () {
      console.log('foo');
    }).finally(function(){
      console.log('foo');
    });

Functions are not var'd they are always named.

GOOD

function myFunction () {
  return 'MyResponse'
}

BAD

var myFunction = function () {
  return 'MyResponse'
}

We always put a space between our function definition and the ( and there is also a space before every {

GOOD

function myFunction () {

}

BAD

function myFunction(){

}

BAD

function myFunction() {

}

BAD

function myFunction (){

}

We always use braces around if's and else's. Also spacing is like that of functions. Else's are formatted like so } else {

GOOD

if (isTruthy) {
  console.log('It\'s super truthy!')
} else {

}

BAD

if (isTruthy)
  console.log('It\'s super truthy')

Jade

Attributes are alphabetical

GOOD

div(
  bar = "foo"
  foo = "bar"
)

BAD

div(
  foo = "bar"
  bar = "foo"
)

There are no commas after attributes

GOOD

div(
  bar = "bar"
  foo = "foo"
  baz = "baz"
)

BAD

div(
  bar = "bar",
  foo = "foo",
  baz = "baz"
)

Naming

PSA - new naming standards for views and directives… instead of viewFancySelect it’s fancySelectView we are trying to slowly migrate all our views to have view at the end rather than the beginning.

And for modals its newContainerModalView instead of viewNewContainerModal