tslint-clean-code
tslint-clean-code copied to clipboard
New rule: avoid-if-else
http://blog.timoxley.com/post/47041269194/avoid-else-return-early
Use of if-else is always unnecessary, and leads to cyclomatic complexity. Other clean code linters (phpmd, golint) enforce this pattern. Would love to have this rule as I have to enforce it manually in my typescript projects right now.
May be related to https://github.com/ajafff/tslint-consistent-codestyle/blob/master/docs/no-else-after-return.md
Such rules are similar but not quite what I need. They only enforce that if the if
branch has a return, else
is unnecessary. We expressly forbid use of else
, period. In SRP code it is a clear code smell.
Oh I see what you mean now! Pull Requests very welcome! Great idea for a rule.