cartant / rxjs-tslint-rules

TSLint rules for RxJS
https://cartant.github.io/rxjs-tslint-rules/
MIT License
371 stars 22 forks source link

[Request] Define a new rule to enforce to have catchError operator #123

Closed yuwu9145 closed 3 years ago

yuwu9145 commented 3 years ago

Hi,

In our project, we want to enforce every observable to have catchError operator by default. Would this rule be worth adding into this package?

Thanks

cartant commented 3 years ago

Given that TSLint was deprecated some time ago and that the TSLint repo is now archived. I do not plan on adding any additional features/rules to rxjs-tslint-rules.

Beyond that, I'm not sure that a rule that enforces the presence of catchError in all observables would be something that I would want to implement or encourage people to use. While it might be well intentioned, I think that it would be awkward in practice, as observables are often composed from other observables and where the catchError should be placed isn't straightforward. There is also the issue that files are linted one by one and what if an observable in one file doesn't have a catchError, but is never subscribed to directly and is instead composed into observable chains in other files?

yuwu9145 commented 3 years ago

HI @cartant ,

Thanks for your comprehensive explain.

The problem for our team is not everyone wants to construct error handler for http request observable failures, and unhandled http fail status like 400, 500 would cause dead front end UI, which is why we want to have a lint rule to enforce http fail handling. We have centralised all these http request observables into certain files. I guess realistically we could firstly construct our own lint rule applied to these http observable files and see how does it go.