For AI agents: the complete documentation index is available at https://rslint.rs/llms.txt, the full documentation bundle is available at https://rslint.rs/llms-full.txt, and this page is available as Markdown at https://rslint.rs/rules/eslint/no-duplicate-case.md.
close

no-duplicate-case

Added in v0.2.2

Configuration

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

export default defineConfig([
  js.configs.recommended,
  {
    rules: {
      'no-duplicate-case': 'error',
    },
  },
]);

Rule Details

Disallow duplicate case labels in switch statements. Duplicate case labels indicate a probable mistake.

Examples of incorrect code for this rule:

switch (a) {
  case 1:
    break;
  case 1:
    break;
}

switch (a) {
  case 'a':
    break;
  case 'a':
    break;
}

Examples of correct code for this rule:

switch (a) {
  case 1:
    break;
  case 2:
    break;
}

switch (a) {
  case 'a':
    break;
  case 'b':
    break;
}

Original Documentation