Skip to content

Instantly share code, notes, and snippets.

@kvz
Created September 8, 2015 14:02
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save kvz/4b810a2ab64cfcc3b0d1 to your computer and use it in GitHub Desktop.

A truly great & short book on CoffeeScript http://arcturo.github.io/library/coffeescript/index.html

I would propose these exceptions to https://github.com/polarmobile/coffeescript-style-guide:

  • we can use a max line length of 100
  • we can also use @todo(user) for annotation
  • we can use alignment for readability
  • we use double quotes everywhere
  • we try to avoid if foo at the end of lines
  • we use a final return x vs just plain x
  • one newline after every early return
  • one newline before every final return
  • one newline before every if statement (unless at the top of a function)
  • we void concatenation where possible using "Hi #{var}". Unless in the example of functions. e.g.: "#{parts[0].substr(01)}/#{file}"

For files:

  • Classes get their own file
  • This means you can modules.export = ClassName vs modules.export.ClassName = ClassName
  • any file containing a class will be named CamelCase.coffee
  • classes their tests will be named testCamelCase.coffee
  • all other files be lower-case-dashed.coffee
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment