简体   繁体   中英

How to fix requireShorthandArrowFunctions

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

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

        resolve('success');

    });
};

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");
});

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM