Last active
February 25, 2020 20:54
-
-
Save cowboy/d29d24f3dbfb26cc33aa to your computer and use it in GitHub Desktop.
JavaScript: chained method indentation
This file contains hidden or 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
// Inspired by the eslint-plugin-react wrap-multilines rule | |
// https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/wrap-multilines.md | |
// | |
// I don't know why, but this is making me really happy right now. | |
// Instead of this | |
var someName = namespace.someObj.method1({ | |
prop: 'value', | |
}).method2('foo', 'bar'); | |
// Or this | |
var someName = namespace.someObj | |
.method1({ | |
prop: 'value', | |
}) | |
.method2('foo', 'bar'); | |
// Do this | |
var someName = ( | |
namespace.someObj | |
.method1({ | |
prop: 'value', | |
}) | |
.method2('foo', 'bar') | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The parens aren't required, I just like how they feel like a visual "container" to me.