Product used: SonarCloud
Language: JavaScript (Node)
Rule: [javascript:S4123] “await” should only be used with promises
When you require()
an async
function from another module, SonarCloud seems unaware that it is async
, and therefore flags it as a code smell when you await
it.
index.js
const foo = require('./foo');
(async () => {
console.log(await foo()); // SonarCloud complains here
)();
foo.js
module.exports = async () => 'foo';