question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Rule proposal: `no-implicit-return-on-newline`

See original GitHub issue

When 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:closed
  • Created 7 years ago
  • Comments:14 (8 by maintainers)

github_iconTop GitHub Comments

1reaction
platinumazurecommented, Apr 28, 2016

Could you please refine your incorrect example so it would parse successfully? (You’re missing a trailing parenthesis)

0reactions
nzakascommented, Aug 31, 2016

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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found