Always braces around arrow function body

JavaScript pattern

Converts arrow function single expression to to block body


Apply with the Grit CLI
grit apply es6_arrow_function_braces

Transform function expressions

TS
const shortSum = (a: number, b: number) => {
  return a + b;
};

const add2 = (a: number) => {
  return a + 2;
};

const getCode = () => {
  return { code: 'CC' };
};

const sum = (a: number, b: number) => {
  return a + b;
};

const getPerson = () => {
  return {
    name: 'John',
    age: 30,
  };
};

const sum = (a: number, b: number) => {
  console.log();
};

const log = () => {
  console.log('Hello');
  console.log('World');
};

const log2 = (arr) => {
  return console.log(arr);
};