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
- New: `except-object` option for `arrow-body-style` rule. (fixes #5936) Blockless arrow functions are awesome, but when returning an object literal it's necessary to enclose the return value in parent... — committed to duncanbeevers/eslint by duncanbeevers 8 years ago
- New: `except-object` option for `arrow-body-style` rule. (fixes #5936) Blockless arrow functions are awesome, but when returning an object literal it's necessary to enclose the return value in parent... — committed to duncanbeevers/eslint by duncanbeevers 8 years ago
- Update: Option for object literals in `arrow-body-style` (fixes #5936) — committed to eslint/eslint by alberto 8 years ago
- Update: Option for object literals in `arrow-body-style` (fixes #5936) — committed to eslint/eslint by alberto 8 years ago
- Update: Option for object literals in `arrow-body-style` (fixes #5936) — committed to eslint/eslint by alberto 8 years ago
- Update: Option for object literals in `arrow-body-style` (fixes #5936) — committed to eslint/eslint by alberto 8 years ago
- Update: Option for object literals in `arrow-body-style` (fixes #5936) — committed to eslint/eslint by alberto 8 years ago
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.