Mozilla Jetpack Coding Style
Published:
Coding Style
- 2-column indentation
- 80-character limit for all lines
- single quotation
' over double quotation " - but keep files general style
- use
let, not var
- dots at end of line, not front (cross-newline “concatenators”)
- Use
camelCase for functions and variables.
- capitalized
CamelCase for classes / constructor functions
- filenames in all lowercase (to avoid confusion on case-sensitive platforms) - should end in
.js and should contain no punctuation except for -.
- no parenthesis for single-line-blocks
- no newline in front of opening curly brace
- newline in front of else (
}\nelse {)
- one branch needs braces -> all branches need braces
- trible equal
=== over double equal ==
- (separate) functions over closures
- JSDoc for functions - definitely for exported ones, encouraged for internal functions
- single line comments
//
- full sentence comments preferred - correct punctuation
- backtick identifiers
`uri` (in comments)