Versions: SQ 8.3, scanner 4.3.0, TS plugin 2.1, JS plugin 6.2.1
Rule: typescript:S1105
I’m getting flagged for
if (!start || !stop) { return; }
else { return `${start} - ${stop}`; }
The help text for this rule ends with the “compliant” example if(condition) {doSomething();} so clearly same-line (short) if-conditionals are valid. How is a short else supposed to be formatted, if not as in my example above?
In this specific case I will probably refactor to
if (!start || !stop) { return; }
return `${start} - ${stop}`;
because the else doesn’t actually change control flow, but that’s not always going to be the case. I know that the default “one true brace” style would have the second and third braces on the same line, before and after the else, but that requires turning these two lines into five, which seems like a waste.