sreginogemoh sreginogemoh - 1 year ago 123
TypeScript Question

tslint onle line rule misplaced 'else'

I have such

one line rule

one-line": [true,

When I have code lines like that:

if(SomethingTrue) { next("a"); }
else { next("b"); }

I've got warning:

(one-line) file.ts[17, 9]: misplaced 'else'

Why that is happens?
Is it bad practice to have one
line else

Answer Source

You have :

else { next("b"); }

Else must be one one line. So:

else { 

Is it bad practice to have one line else?

Just easier to read. Its a styleguide for consistency.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download