I have the following code:
for await (const ele of offCycles) {
if ((await MlQueueModel.find({ uuid: ele.uuid })).length !== 0) {
continue;
}
<do something>
}
Is it possible to use a continue inside a for await loop ?
I received the following error:
Unexpected use of continue statement.eslintno-continue
I would like to continue the loop when the condition is true
2
Answers
The error is just a coding style issue instead of an actual error in JavaScript. Some argues that using
continue
statement is a bad practise but generally it is quite opinionated.You can disable the rule by adding
"no-continue": "off"
in your eslint config so that you can use it. Read more about the use of this rule here: https://eslint.org/docs/latest/rules/no-continueI have found this interesting question here that will explain to you about the use of
continue
/break
: https://softwareengineering.stackexchange.com/questions/434124/are-there-any-problems-with-using-continue-or-breakBasically, if you know what you are doing, then it is not an issue.
That’s an eslint error, not a JavaScript error.
You can: