💼 This rule is enabled in the ✅ recommended
config.
Asynchronous operations are much harder to reason about in loops. To increase maintainability, asynchronous operations should not be placed within loops.
The following patterns are considered warnings:
QUnit.test("Test name", function () {
while (false) { QUnit.stop(); }
});
QUnit.test("Test name", function () {
while (false) { QUnit.start(); }
});
QUnit.test("Test name", function (assert) {
while (false) { assert.async(); }
});
QUnit.test("Test name", function () {
do { QUnit.stop(); } while (false);
});
QUnit.test("Test name", function () {
do { QUnit.start(); } while (false);
});
QUnit.test("Test name", function (assert) {
do { assert.async(); } while (false);
});
QUnit.test("Test name", function () {
for (;;) { QUnit.stop(); }
});
QUnit.test("Test name", function () {
for (;;) { QUnit.start(); }
});
QUnit.test("Test name", function (assert) {
for (;;) { assert.async(); }
});
QUnit.test("Test name", function () {
for (i in obj) { QUnit.stop(); }
});
QUnit.test("Test name", function () {
for (i in obj) { QUnit.start(); }
});
QUnit.test("Test name", function (assert) {
for (i in obj) { assert.async(); }
});
QUnit.test("Test name", function () {
for (i of obj) { QUnit.stop(); }
});
QUnit.test("Test name", function () {
for (i of obj) { QUnit.start(); }
});
QUnit.test("Test name", function (assert) {
for (i of obj) { assert.async(); }
});
The following patterns are not warnings:
QUnit.test("Test name", function () {
QUnit.stop();
QUnit.start();
});
QUnit.test("Test name", function (assert) {
var done = assert.async();
});
This rule can be disabled if it is common to write async setup or resolution calls in loops in your codebase.