I have a function that returns a Promise like this:
async function processFolder(folder) {
return new Promise(async (res) => {
const table = {};
const list = await getHTMLlist(folder);
if (list.length === 0) res(table);
for (let i = 0; i < list.length; i++) {
await processFile(folder, list[i], table);
}
res(table);
});
}
I'm using ESLint that warn me:
"Promise executor functions should not be async" that is the no-async-promise-executor rule that throw an error due to the async keyword in the Promise declaration.
I have already fixed the same problem in other parts of the code where there was only one await inside the Promise using the technique suggested on this page of the ESLint documentation and showed in this answer, but in my use case I don't really know how to refactor the code in order to avoid that error. Any suggestions are welcome