These guides are for keeping track of how we write code. We're aiming for both consistency and best practice, so that we can create clean and sustainable code. With everyone working towards the same style and structure, it makes working together that little bit easier! 👯
- Consistency of coding style is more important than adhering to any coding standard. If you’re working with an existing project or framework, use its existing style.
- Comment everything non-trivial (and even trivial things, if you like).
- Be clear, and as verbose as you like.
- Over-commenting is better than under-commenting.
- Write for your future self as much as anyone else.
- Go for readability over compression.
- Plenty of whitespace!
- If a longer variable name makes the code more readable, do it!
- Let the build tools do the compression.
Install the EditorConfig plugin for your text editor and try to use an .editorconfig
file when you're starting a new project.
To avoid inconsistencies and confusing diffs, try to stick to the following:
- Use soft tabs with 2 spaces.
- Trim trailing white space on save.
- Set encoding to UTF-8.
- Add new line at the end of files.
These guides are influenced by lots of great work that's already out there, including:
- Styleguide by Github
- Code Guide by @mdo
- Guides by thoughbot
- HTML/CSS Style Guide by Google
- Codepen's CSS by Chris Coyier
- Github's CSS by @mdo
- CSS at Lonely Planet by Ian Feather