# No hardcoded `process.env.NODE_ENV === 'development'` blocks with empty else

- **Pattern:** `ab-000273` (`ai-slop-half-finished.dev-artifacts.unused-esbuild-markers`)
- **Severity:** low
- **Lifecycle:** active
- **Last modified:** 2026-04-18
- **Canonical URL:** https://auditbuffet.com/patterns/ab-000273
- **License:** CC-BY-4.0 — attribute to AuditBuffet Pattern Catalog (https://auditbuffet.com/patterns/ab-000273)

## Why it matters

A bare `if (process.env.NODE_ENV === 'development') { console.log(state) }` with no else branch marks code as dev-only but ships it anyway — the gate evaluates at runtime, not build time, so the branch stays in the production bundle and fires for anyone whose `NODE_ENV` is misconfigured. More often it is just dead clutter left behind from debugging sessions, and it signals poor code-quality hygiene across the repo.

## Severity rationale

Low because the impact is mostly bundle bloat and noise, but clustered markers indicate broader cleanup gaps.

## Remediation

Remove orphaned debug blocks or route them through a real logging library that handles levels and production silencing. A single `logger.debug()` is cleaner than an inline `NODE_ENV` check and gives you a kill switch. Fix at `src/store/index.ts`:

```ts
import { logger } from '@/lib/logger'
logger.debug('state', state)
```

## Detection

- **ID:** `unused-esbuild-markers`
- **Severity:** `low`
- **What to look for:** Walk all source files for `if (process.env.NODE_ENV === 'development') { ... }` blocks (or equivalent `!== 'production'` variants). For each, check whether the block has a corresponding `else` branch. Count all dev-only blocks with NO else branch AND whose body contains only debug code (console.log, alert, debugger). These are usually dead code markers that were never cleaned up.
- **Pass criteria:** 0 dev-gate blocks with debug-only bodies and no else branch. Report: "Scanned X source files, 0 dead dev markers."
- **Fail criteria:** At least 1 dev-only `if` block exists with no else and contains only debug output.
- **Skip (N/A) when:** Project has 0 source files with `NODE_ENV` checks.
- **Detail on fail:** `"2 dead dev markers: 'if (NODE_ENV === \"development\") console.log(state)' in src/store/index.ts, 'if (NODE_ENV !== \"production\") debugger;' in src/components/Chart.tsx"`
- **Remediation:** These are usually leftover debug statements that were conditionally enabled but never removed. Either remove them or move them behind a proper logging library that handles production gracefully:

  ```ts
  // Bad: dev marker left behind
  if (process.env.NODE_ENV === 'development') {
    console.log('state:', state)
  }

  // Good: use a proper logger
  import { logger } from '@/lib/logger'
  logger.debug('state', state)
  ```

Taxons: placeholder-hygiene, code-quality

HTML version: https://auditbuffet.com/patterns/ab-000273
