Glavin001 / tslint-clean-code

TSLint rules for enforcing Clean Code
https://www.npmjs.com/package/tslint-clean-code
MIT License
169 stars 15 forks source link

New rule: avoid-if-else #39

Open froodley opened 6 years ago

froodley commented 6 years ago

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.

Glavin001 commented 6 years ago

May be related to https://github.com/ajafff/tslint-consistent-codestyle/blob/master/docs/no-else-after-return.md

froodley commented 6 years ago

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.

Glavin001 commented 6 years ago

Oh I see what you mean now! Pull Requests very welcome! Great idea for a rule.