VBC-068: overuse-ternary
warningCategory: clean-code
Analysis: Regex (line by line)
File types: .js, .ts, .tsx, .astro
Scope: source code only, ignoring anything inside strings and comments
Tags: clean-code
What it reports
Chained or nested ternary at line {line}. Stacked conditionals are hard to read and hard to debug; use an if/else block or a lookup table.
Flagged
js
const size = big ? 'lg' : medium ? 'md' : 'sm';Not flagged
js
const size = big ? 'lg' : 'sm';js
function f(a?: string, b?: number) {}Pattern
regex
\?(?![.:])[^\n]*?:[^\n]*?\?(?![.:])[^\n]*?:|\?(?![.:])[^\n]*?\?(?![.:])[^\n]*?:[^\n]*?: