How to fix requireShorthandArrowFunctions

122 Views Asked by At

How to fix this requireShorthandArrowFunctions arrow function so that it is compliant with JSCS?

const doSomething = () => {
    return new Promise((resolve, reject) => {

        resolve('success');

    });
};
1

There are 1 best solutions below

0
Adaz On

I know this is old but I just had the same issue. I figured out it's because your doSomething function does only one thing - it returns a promise. So, technically you shouldn't use a return statement and curly braces:

const doSomething = () => new Promise((resolve, reject) => {
    resolve("success");
});