Raindrop/CodeStyle: Difference between revisions

From MozillaWiki
Jump to navigation Jump to search
(Created page with '== Code Style == Here are some style guidance for the Raindrop code. === JavaScript === All code should conform to the [http://www.jslint.com/lint.html JSLint] style. Big high…')
 
 
Line 10: Line 10:
* One var call per function.
* One var call per function.
* Always use braces around blocks.
* Always use braces around blocks.
* Prefer camelCase always instead of using_underscores. The back-end data model will have fields that have underscores, those are fine to reference. But for things that exist in just the front end code, camelCase is preferred, including in file names.


To validate your code, here are some options:
To validate your code, here are some options:

Latest revision as of 18:09, 27 April 2010

Code Style

Here are some style guidance for the Raindrop code.

JavaScript

All code should conform to the JSLint style. Big highlights:

  • 4 spaces for indentation, using spaces, not tabs.
  • One var call per function.
  • Always use braces around blocks.
  • Prefer camelCase always instead of using_underscores. The back-end data model will have fields that have underscores, those are fine to reference. But for things that exist in just the front end code, camelCase is preferred, including in file names.

To validate your code, here are some options:

  • Use the online website
  • If using Komodo or Komodo Edit, there is JSLint add-on. Go to Tools, Add-Ons, then click the Get Add-ons button, and search for "jslint".
  • Use the dvcs_jslint to hook up JSLint as a pre-commit step for Mercurial.

All documentation for the JavaScript should be done in JSDoc format.