Skip to content

Instantly share code, notes, and snippets.

@jpwilliams
Last active March 16, 2017 10:22
Show Gist options
  • Save jpwilliams/cb7b5fb28dfe1a529b24d1e6e275dc2d to your computer and use it in GitHub Desktop.
Save jpwilliams/cb7b5fb28dfe1a529b24d1e6e275dc2d to your computer and use it in GitHub Desktop.
Valid places to break chained and function calls
// Always break for args > 2
// All of the following are valid examples
// usual
myFunc(one, two)
// > 2 args
myFunc(
one,
two,
three
)
// usual chain
myChain.is.Ready()
// >2 args in chain
myChain
.is
.not
.Ready()
// usual chain within a function call
myFunc(myChain.is.Ready(), another.one())
// usual chain within a function call with > 2 args
myFunc(
myChain.is.Ready(),
another.one(),
and.another.one()
)
// >2 args chain within a function call
myFunc(
myChain
.is
.not
.Ready(),
another.one()
)
// >2 args chain within a function call with >2 args
myFunc(
myChain
.is
.not
.Ready(),
another.one(),
and
.heres
.another
.one()
)
// Objects as the first parameter of a function can start on the same line if no
// other line breaks are needed
myFunc({
has: 'an',
object: true
}, another.one())
myFunc(
{
has: 'an',
object: true,
},
myChain
.is
.not
.Ready()
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment