newline-before-continue

Group
Style
Path
lint/style/newline-before-continue
Default
Off, opt in
Origin
Falcon
Rule
276 of 512

Requires a blank line before a continue that follows another statement.

Checks labeled and unlabeled continues in blocks. First statements, unbraced continues, and switch-case lists are exempt. Blank lines above comments count.

Invalid

example.dartdart
void loops(bool condition) {
  while (condition) {
    print('before');
    continue;
  }
  outer: for (var i = 0; i < 3; i++) {
    while (condition) {
      print('nested');
      continue outer;
    }
  }
}

void commented(bool condition) {
  while (condition) {
    print('before');
    // No separating blank line.
    continue;
  }
}
Add a blank line before this `continue` statement.
3 print('before');
4 continue;
Add a blank line before this `continue` statement.
8 print('nested');
9 continue outer;
Add a blank line before this `continue` statement.
17 // No separating blank line.
18 continue;

Valid

example.dartdart
void loops(bool condition) {
  while (condition) {
    continue;
  }
  while (condition) {
    print('before');

    continue;
  }
  outer: for (var i = 0; i < 3; i++) {
    while (condition) {
      continue outer;
    }
  }
  while (condition) {
    if (condition) continue;
  }
}

void cases(int value) {
  while (true) {
    switch (value) {
      case 0:
        print(value);
        continue next;
      next:
      default:
        return;
    }
  }
}

void commented(bool condition) {
  while (condition) {
    print('before');

    // Start another iteration.
    continue;
  }
}

Configure newline-before-continue

Set its severity in falcon.json. See the configuration guide.

falcon.jsonjson
{
  "linter": {
    "rules": {
      "style": {
        "newline-before-continue": "error"
      }
    }
  }
}

Or silence one occurrence with a suppression comment; the reason is required.

example.dartdart
// falcon-ignore lint/style/newline-before-continue: <reason>