Rule proposal: `no-implicit-return-on-newline`
See original GitHub issueWhen does this rule warn? Please describe and show example code:
This rules checks that ES6 arrow functions that use implicit return do so on the same line as their parameters.
Correct:
// ex 1
someArray.map((value, index) => value + 1);
// ex 2
processAsync()
.then(result => result
.moreAsync()
.then(final => Object.assign({}, final, { foo: 'bar' })));
Incorrect:
// ex 1
someArray.map((value, index) =>
value + 1);
// ex 2
processAsync()
.then(result =>
result
.moreAsync()
.then(final =>
Object.assign({}, final, { foo: 'bar' })));
Is this rule preventing an error or is it stylistic?
Purely stylistic. I find it much easier to process source-code if I can assume that same-line arrow-functions return and code blocks will explicitly return
.
Why is this rule a candidate for inclusion instead of creating a custom rule?
This would benefit to any JS developers who also find it easier this way.
Are you willing to create the rule yourself?
Yes, if the rule makes sense to others.
Issue Analytics
- State:
- Created 7 years ago
- Comments:14 (8 by maintainers)
Top Results From Across the Web
Rule Proposal: nonblock-body-position · Issue #6067 - GitHub
This rule will enforce the position of bare statements at the body of if, else, ... Rule proposal: no-implicit-return-on-newline #5989.
Read more >implicit-arrow-linebreak - ESLint - Pluggable JavaScript Linter
This rule aims to enforce a consistent location for an arrow function containing an implicit return. Options. This rule accepts a string option:...
Read more >Arrow function implicit return wrapped automatically with ...
Yes, there's a return in there, and it gets "prettified" due to the assignment. The only two options for this rule are to...
Read more >Arrow Functions · Styleguide JavaScript
If the function body consists of a single statement returning an expression without side effects, omit the braces and use the implicit return....
Read more >How can I '\input' a file without getting the implicit newline? - TeX
I'm working on a lightweight package that allows you to put any content (typically LaTeX code) in an environment, then use that content...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Could you please refine your incorrect example so it would parse successfully? (You’re missing a trailing parenthesis)
Unfortunately, it looks like consensus couldn’t be reached on this issue and so I’m closing it. While we wish we’d be able to accommodate everyone’s requests, we do need to prioritize. We’ve found that issues failing to reach consensus after 21 days tend never to reach consensus, and as such, we close those issues. This doesn’t mean the idea isn’t interesting, just that it’s not something the team can commit to.