Arrow function should use parentheses to return an object literal
- ARROW_FUNC_RETURN_OBJECT_MISSING
- Error
- Medium
- es6
This rule applies when an arrow function tries to return an object literal improperly.
At the start of arrow function's body, {
is regarded as a block statement. To return an object literal properly, use parentheses.
Noncompliant Code Example
View with compliant examples side by sideconst func = num => { square: num * num }; // ARROW_FUNC_RETURN_OBJECT_MISSING alarm because an object literal is not returned.
Compliant Code Example
View with noncompliant examples side by sideconst func = num => ({ square: num * num });
Version
This rule was introduced in DeepScan 1.8.0-beta.