VBC-054: unnecessary-else
warningCategory: clean-code
Analysis: Regex (whole file)
File types: .js, .ts, .tsx, .astro
Scope: source code only, ignoring anything inside strings and comments
Tags: clean-code
What it reports
Unnecessary 'else' after 'return' at line {line}. Remove the else and flatten the code.
Flagged
js
if (ready) {
return 1;
} else {
return 2;
}Not flagged
js
if (ready) {
start();
} else {
stop();
}Pattern
regex
\breturn\b[^\n]*;?\s*\n?\s*\}\s*else\s*\{