Last active
March 16, 2017 10:22
-
-
Save jpwilliams/cb7b5fb28dfe1a529b24d1e6e275dc2d to your computer and use it in GitHub Desktop.
Valid places to break chained and function calls
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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