AI Patternswarnstrict preset

ai-guard/no-dead-branch

Finds unreachable conditional branches and dead code left behind by AI scaffolding

What it does

Why AI tools generate this pattern

Code Examples

Incorrect (Flagged by AI Guard)
// Bad example
Correct (Safe & Deterministic)
// Good example

How to Fix

  1. Follow the good example above and handle or avoid the flagged pattern appropriately.

Nuances & False Positive Prevention

Legitimate usage can be exempted with inline disable comments (// ai-guard-disable-next-line no-dead-branch) when appropriate.

Configuration

Enable or override this rule in your ESLint configuration:

eslint.config.mjs
// eslint.config.mjs
export default [
  {
    plugins: { 'ai-guard': aiGuard },
    rules: {
      'ai-guard/no-dead-branch': 'warn',  // or 'error' or 'off'
    },
  },
];

Related Rules