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-dupe-else-if.md.
close

no-dupe-else-if

Added in v0.5.0

Configuration

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

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

Rule Details

Disallow duplicate conditions in if-else-if chains. If an else if condition is identical to a previous condition in the same chain, the branch can never execute.

Examples of incorrect code for this rule:

if (a) {
  foo();
} else if (a) {
  bar();
}

if (a) {
  foo();
} else if (b) {
  bar();
} else if (a) {
  baz();
}

Examples of correct code for this rule:

if (a) {
  foo();
} else if (b) {
  bar();
}

if (a === 1) {
  foo();
} else if (a === 2) {
  bar();
}

if (a) {
  foo();
} else if (b) {
  bar();
} else {
  baz();
}

Original Documentation