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

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 });

About this issue

  • Original URL
  • State: closed
  • Created 8 years ago
  • Reactions: 1
  • Comments: 37 (37 by maintainers)

Commits related to this issue

Most upvoted comments

I think we should favor new contributions here.

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

I think this is a fair request.