Open ntraut opened 3 years ago
so return await thing();
doesn't work, but what about await thing(); return
?
so
return await thing();
doesn't work, but what aboutawait thing(); return
?
It would prevent to do an async one line arrow function, but in this case why forbidding return await? According to the explanations of the rule (https://eslint.org/docs/rules/no-return-await), the goal is to avoid an unnecessary micro task but if we decompose we have it.
something like const result = (arg) => await thing(arg)
? I don't think you need the return
there. But change the eslint config as you think it's better! :D
something like
const result = (arg) => await thing(arg)
? I don't think you need thereturn
there. But change the eslint config as you think it's better! :D
In a one line arrow function the return is implicit and eslint considers there is one. Your syntax is not correct since you use await in a non async function, but const result = async (arg) => await thing(arg)
will break the no-return-await
rule and const result = async (arg) => thing(arg)
will break the require-await
rule. The only syntax which doesn't break any rule is const result = (arg) => thing(arg)
but we no longer see that result
is an async function.
I see now. Thank you :)
As pointed out in this issue if we have both
require-await
andno-return-await
rules turned on, when the only call to an async function is on the return statement we get an error whatever we use await or not. We should disable at least one these rules.