Over a million developers have joined DZone.

CoffeeScript Style Guide

DZone's Guide to

CoffeeScript Style Guide

· Web Dev Zone
Free Resource

Learn how to build modern digital experience apps with Crafter CMS. Download this eBook now. Brought to you in partnership with Crafter Software

You may have come across the GitHub JavaScript Styleguide, which tells us to:

"Write new JS in CoffeeScript." 

 That alone is an awesome endorsement of the "little language", but there is more good advice:

"Follow @jashkenas's style. See the documentation for good examples." 

Without doubt, this is correct. The CoffeeScript home page should be your first stop for style. However, it's not strictly a style guide, so for a more dedicated resource I recommend  polarmobile/coffeescript-style-guide. It answers questions such as "tabs or spaces?", and I expect it will continue to grow, becoming a very comprehensive resource.

Of course, you could argue that in the age of computer automation, the best style guides are linters. CoffeeLint is described as "a style checker that helps keep CoffeeScript code clean and consistent." For style consistency across a team, it's likely to be a great choice.

Finally, as an example of good CoffeeScript style in the context of hairy, real-world programming, Jeremy Ashkenas recommends  the source code for the Pow server.

This list is by no means complete and is open for your contributions. Where do you go for great CoffeeScript style?

Crafter is a modern CMS platform for building modern websites and content-rich digital experiences. Download this eBook now. Brought to you in partnership with Crafter Software.


Published at DZone with permission of Chris Smith, DZone MVB. See the original article here.

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}