-
For indentation use 4 spaces
-
Always try to limit your lines to 80 characters unless it breaks readability, then it can go up to a max of 120 characters
-
End every file with a empty line at the bottom
-
Avoid extraneous whitespace
YES: spam(cat[1], {dog: 2}) NO: spam( cat[ 1 ], { dog: 2 } )
-
Use early return when creating methods
-
Make sure everything passes hinting
-
When creating a locally referenced scope variable use the variable name
self
-
Always use camelCase
-
When naming your modules/packages, only use lowercase without any -_. character. Example:
/awesomepackage/cutecat.js
YES: `/awesomepackage/cutecat.js` NO: `/awesomePackage/cuteCat.js`
-
Place all imports at the top
-
Separate top imports with your implementation with two blank lines
-
Use a blank line between node and distributed imports and project specific
-
Imports should be declared as vars on a new line. Example:
var env = require("node-env-file"); var winston = require("winston"); var fundamentet = require("./fundamentet");
-
When organizing imports, use the following order:
- Core modules shipped in Node
- Third part modules
- Project modules
- Always remove console.log messages when checking in your code (unless it is really neccessary).
- TODO: Look into log wrappers
- Put all your export declarations last
- Always use
module.exports
when exporting, notexport
- Try to keep the inline comments to a minimum
- When creating a new module, always write a documentation in the header that explains what the module does
- When defining callbacks, always include a error parameter first
- Make sure that you always return the result of your callbacks
- Use early returns