Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rule idea: no-unnecessary-combinelatest #107

Open
bmarcotte opened this issue Feb 1, 2023 · 0 comments
Open

Rule idea: no-unnecessary-combinelatest #107

bmarcotte opened this issue Feb 1, 2023 · 0 comments

Comments

@bmarcotte
Copy link

One issue that we keep finding in our codebase (a surprisingly large number of times): using combineLatest for only one observable. Usually, it's the result of refactoring code, that originally had multiple observables passed in, until it has only one left, but then forgetting to remove the combineLatest.

For example, code like this:

combineLatest([
  this.fooService.get$(),
  this.barService.get$()
]).subscribe(...)

...often gets refactored into something like this:

combineLatest([
  this.fooBarService.get$()
]).subscribe(...)

...and then we'll forget to remove the now unnecessary combineLatest call. If this plugin could somehow flag occurrences of the latter, it would be a huge help to us.

FYI, to help avoid edge cases, this would still be valuable to us even if it is was limited to only checking when combineLatest is declared with an array literal, like above, and should skip checking if an array variable is passed in, since that might not have a checkable length until runtime. e.g.:

observables = [of(1)];
combineLatest(observables).subscribe(...)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant