Just because
All questions of style not covered in this guide should defer to the Airbnb JavaScript Style Guide.
Nope. They are unnecessary and ugly.
Lines beginning with a (
or [
should be avoided. They risk becoming function calls and array accesses in a semicolonless world. If they must be used (e.g., for an IIFE), they should be prefixed with a semicolon.
Limit lines to 79 characters. This is still useful for editing multiple files on a 13-inch Macbook Pro.
Wrapped lines should be indented four spaces. E.g.:
if ((myVeryLongConditional1 && myVeryLongConditional2) ||
myOtherPossibleConditional3) {
//...
}
const result = myModule.myVeryLongFunctionCallName(longArgName1,
longArgName2, longArgName3)
When wrapping lines with operators, the operator should fall at the end of the line. This includes boolean operator, ternary operators, and arithmetic operators, e.g., in string concatenation.
const myLongErrorMessage = 'Lines must end with an operator at the end.' +
'Do not put the operator at the beginning!'
const myTernary = longConditionalQuestion ?
module.doOneVerboselyNamedThing() :
module.doAnotherVerboselyNamedThing()