quick-lint-js

Find bugs in JavaScript programs.

E0200: break can only be used inside of a loop or switch

A break statement exits a do-while loop, for loop, while loop, or switch statement. It is a syntax error for a break statement to appear outside these loops or a switch statement:

friends.forEach((friend) => {
  hand.giveHighFive(friend);
  if (hand.isTired) {
    break;
  }
});

To fix this error, write a for-of loop instead of using the forEach method:

for (const friend of friends) {
  hand.giveHighFive(friend);
  if (hand.isTired) {
    break;
  }
}

Introduced in quick-lint-js version 0.2.0.

Documentation for other errors