You are welcome to fork this repository. We'd love getting pull requests.
Here are some recommendations for setting up your environment so that the code you write smells like the main project.
- jslint/jshint all the things!
- editorconfig so we have the same spacing style
- phantomjs - to automatically run all the qunit tests for you
- Mac -
brew install phantomjsis the easiest. Alternatives
- Mac -
We recommend Test Driven Development be used, and we aim for 100% coverage. If you use
grunt watch, you can have it run the tests every time you write a file.
We use travis-ci for automagic testing on every commit. Current test status:
In order to ensure high quality code, we ask that contributors follow some coding standards.
Our overarching principals are simplicity, readability, and maintainability. We'll also borrow some ideas from Python
Beautiful is better than ugly. Explicit is better than implicit. Simple is better than complex. Complex is better than complicated. Flat is better than nested. Sparse is better than dense. Readability counts. Special cases aren't special enough to break the rules. Although practicality beats purity. Errors should never pass silently. Unless explicitly silenced. In the face of ambiguity, refuse the temptation to guess. There should be one-- and preferably only one --obvious way to do it. Although that way may not be obvious at first unless you're Dutch. Now is better than never. Although never is often better than *right* now. If the implementation is hard to explain, it's a bad idea. If the implementation is easy to explain, it may be a good idea. Namespaces are one honking great idea -- let's do more of those!
And we think that pretty much covers it.
- Spaces, not tabs. 4 of them. Pro tip: Use an editor that supports editorconfig, and this will be handled for you.
- Minification is the computer's job, not yours. Use explicit variable names.
- Braces on the same line, or I am afraid this won't work out.
- Cleverness is seldom required. When it is, comment it.
- Be considerate of other contributors. Will someone that reads your code later understand what you've done?
- Names matter. Use names that make sense for clarity.
- Minimized assume globals, explicitly reference
windowwhen you need to.
- Always use semicolons;
- Always use braces, no one-line shortcuts.
- Triple equals where it is a good idea. Don't leave type to chance.
Have a suggestion? Fork this page and issue a pull request! :)
Here are a few interesting resources: