Rule: arrow-return-shorthand

Suggests to convert () => { return x; } to () => x.

Rationale

It’s unnecessary to include return and {} brackets in arrow lambdas. Leaving them out results in simpler and easier to read code.

Notes:
Has Fixer

Config

If multiline is specified, then this will warn even if the function spans multiple lines.

Config examples
"arrow-return-shorthand": true
"arrow-return-shorthand": [true, "multiline"]
Schema
{
  "type": "string",
  "enum": [
    "multiline"
  ]
}

Code examples:

Enforces usage of the shorthand return syntax when an arrow function's body does not span multiple lines.
"rules": { "arrow-return-shorthand": true }
Passes
const calc = (x: number, y: number) => ({ add: x + y, sub: x - y, mul: x * y });
const calc2 = (x: number, y: number) => {
    return { add: x + y, sub: x - y, mul: x * y }
};
Fails
const calc = (x: number, y: number) => { return { add: x + y, sub: x - y, mul: x * y } };
const calc2 = (x: number, y: number) => {
    return { add: x + y, sub: x - y, mul: x * y }
};
Enforces usage of the shorthand return syntax even when an arrow function's body spans multiple lines.
"rules": { "arrow-return-shorthand": [true, "multiline"] }
Passes
const calc = (x: number, y: number) => ({ add: x + y, sub: x - y, mul: x * y });
const calc2 = (x: number, y: number) =>
    ({ add: x + y, sub: x - y, mul: x * y });
Fails
const calc = (x: number, y: number) => { return { add: x + y, sub: x - y, mul: x * y } };
const calc2 = (x: number, y: number) => {
    return { add: x + y, sub: x - y, mul: x * y }
};