UNPKG

pi-lens

Version:

Real-time code feedback for pi — LSP, linters, formatters, type-checking, structural analysis & booboo

62 lines (50 loc) • 1.2 kB
# Switch Case Termination # Detects switch cases that don't properly terminate id: switch-case-termination name: Switch Cases Should End With Terminating Statement severity: error category: reliability defect_class: correctness inline_tier: blocking language: typescript message: "Switch case should end with break, return, throw, or continue" description: | Switch cases that fall through to the next case cause bugs. Each case should end with break, return, throw, or continue. If fall-through is intentional, add a // fallthrough comment. ✅ FIX: Add terminating statement ```typescript switch (x) { case 1: doSomething(); break; // GOOD } ``` query: | (switch_body (switch_case) @CASE . [(switch_case) (switch_default)]) metavars: - CASE post_filter: no_terminating_statement tags: - reliability - typescript - bugs examples: bad: | switch (x) { case 1: doSomething(); // BAD - falls through case 2: break; } good: | switch (x) { case 1: return "one"; // GOOD - return terminates case 2: break; } has_fix: false