close

no-useless-continue

Added in v0.9.4

Configuration

PresetConfigured Value
✅ unicornPlugin.configs.recommended"error"
rslint.config.ts
import { defineConfig, unicornPlugin } from '@rslint/core';

export default defineConfig([
  unicornPlugin.configs.recommended,
  {
    rules: {
      'unicorn/no-useless-continue': 'error',
    },
  },
]);

Disallow an unlabeled continue statement when the current loop iteration would end at the same point without it. The rule fixes the statement automatically and preserves adjacent comments.

// Incorrect
for (const item of items) {
  process(item);
  continue;
}

// Correct
for (const item of items) {
  process(item);
}

Labeled continue statements, bare loop bodies, and statements inside a switch or try are left alone.

Options

This rule has no options. It is enabled at error severity in unicornPlugin.configs.recommended.

Differences from upstream

When removing a standalone statement from a CRLF file, the fix removes the whole preceding CRLF sequence. Unicorn v76.0.0 removes only the newline byte in this case, leaving an extra carriage return.

Original Documentation