ember-cli / ember-cli/eslint-plugin-ember
named-functions-in-promises
- Dominant language
- JavaScript
- Stars
- 263
- Forks
- 214
- Avg merge
- 30m
- Merged PRs (30d)
- 5
Description
I really like the idea behind this rule, but it needs more tweaking to be useful for my team.
We just tried applying this rule to an app, and we liked what the rule got us to do in 2/10 of the instances . In these there were more than two statements (~6). Extract these to a private function made it more readable. We aren't testing these directly right now anyway, so testing wasn't a factor in this.
In the other 8/10 of them, we didn't like the outcome better than what we'd started with. In each of these, there were just two statements inside our `.then()`.
- It was harder to read as a single extracted private function (indirection).
- It's also harder to read as two then's chained (like the docs suggest). Three people who reviewed the PR separately all asked all why these were chained, and what the "promise" inside the earlier then would return (but it wasn't a promise). I could imagine some teams getting used to this and liking the rule - but it just didn't work for us~
One alternative I can think of might be a threshold "number of statements" a `then()`'s function can contain. We might set ours at >= 4 would fail the rule, and merit being extracted to a private function.
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.