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.

Create `except-object` exception to `arrow-body-style` rule, enforcing explicit return of object literals from arrow functions.

See original GitHub issue

The arrow-body-style rule enforces braceless function bodies when the function consists of a single return statement.

When constructing arrow functions which return object literals, the return value must be wrapped in parentheses to force its evaluation as an expression.

The proposed new option enforces a block body with an explicit return value for object literals returned from arrow functions.

Valid

var foo = () => { return; { bar: 0 }; };
var foo = () => 0;

Invalid

var foo = () => ({ bar: 0 });

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Reactions:1
  • Comments:37 (37 by maintainers)

github_iconTop GitHub Comments

1reaction
mikesherovcommented, Jun 3, 2016

I think we should favor new contributions here.

1reaction
BYKcommented, May 17, 2016

I’m +1 to allowObjectLiteralBody: true suggestion for now. If we get 2 more 👍s I’d say we go with that.

Read more comments on GitHub >

github_iconTop Results From Across the Web

arrow-body-style - ESLint - Pluggable JavaScript Linter
This rule can enforce or disallow the use of braces around arrow function body. ... it requires braces and an explicit return for...
Read more >
Returning Object Literals from Arrow Functions in JavaScript
Here's how to return an object literal from an expression-bodied arrow function as introduced by ECMAScript 2015.
Read more >
ECMAScript 6 arrow function that returns an object
Arrow functions implicitly return the expression on the right side of the arrow. eg p => p * 2 will return the result...
Read more >
getify/eslint-plugin-proper-arrows
The proper-arrows ESLint plugin provides rules that control the definitions of => arrow functions, restricting them to a narrower and more ...
Read more >
ES2015 Arrow Functions
For example, how would we return an object literal using an arrow function? We might naively assume we could do this:
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