It's valid. Since v3.10.1 <https://github.com/eslint/eslint/releases/tag/v3.10.1>, the rule allows `return await` in `try` block.
2017年4月15日(土) 8:01 Sean Dwyer <[email protected]>: > In regard to the no-return-await rule, the docs say the following: > > Inside an async function, return await is useless. Since the return value >> of an async function is always wrapped in Promise.resolve, return await >> doesn’t >> actually do anything except add extra time before the overarching Promise >> resolves or rejects. This pattern is almost certainly due to programmer >> ignorance of the return semantics of async functions. > > > What about a case where I want to catch an error from the function I'm > awaiting like this: > > async function foo() { > try { > return await bar(); > } catch (error) { > console.log('Error caught'); > } > } > > Is this not a valid use of `return await`? > > -- > You received this message because you are subscribed to the Google Groups > "ESLint" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > For more options, visit https://groups.google.com/d/optout. > -- You received this message because you are subscribed to the Google Groups "ESLint" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/d/optout.
