Arrow functions in JavaScript provide a concise syntax to write function expressions. However, the use of braces {} and parentheses
() should be consistent in arrow functions for the following reasons:
Shared coding conventions allow teams to collaborate effectively. This rule raises an issue when using parentheses and curly braces with an arrow function does not conform to the configured requirements.
Use parentheses and curly braces with arrow functions consistently. By default, the rule forbids arrow functions to have parentheses around single parameters and curly braces around single-return bodies.
const foo = (a) => { /* ... */ }; // Noncompliant; remove the parentheses from the parameter
const bar = (a, b) => { return 0; }; // Noncompliant; remove the curly braces from the body
const foo = a => { /* ... */ };
const bar = (a, b) => 0;