4 ms·
Why do you necessarily need a line limit? I would simply indent all chained function calls and be done with it. Eg. return foo(param) .then(bar)
by wheresvic1 9y ago
Why do you necessarily need a line limit?
I would simply indent all chained function calls and be done with it. Eg.
return foo(param)
.then(bar)
.catch(err => {
logger.error(err);
return -1;
});
- xeonoex 9y agoOr just have an allowed limit for 1 liners, then indent all of it the way you suggested if it is surpassed.
- skybrian 9y agoSome style guides have a line limit (including Dart). If you want to submit code without hand-editing, the formatter needs to do it. On the other hand, Go's style guide doesn't have a line limit, so its formatter doesn't have to solve tricky problems like this. Programmers can add line breaks by hand if they get too long. (A nice side effect is that auto-formatting your code doesn't change line numbers.)