neuroanatomy / eslint-config-naat

Style rules for js code at NAAT

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

require-await and no-return-await rules are incompatible

ntraut opened this issue · comments

As pointed out in this issue if we have both require-await and no-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.

so return await thing(); doesn't work, but what about await thing(); return?

so return await thing(); doesn't work, but what about await 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 the return 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 :)