ReactiveX / rxjs-tslint

TSLint rules targeting RxJS
MIT License
309 stars 41 forks source link

Extra comma being added after migration #53

Closed ndcunningham closed 6 years ago

ndcunningham commented 6 years ago

Hi after running: rxjs-5-to-6-migrate -p ./tsconfig.json there seems to be a problem with some of my observable definitions as a comma (,) is being added at the end of the chain.

Please see some examples below:

BEFORE

 return this.httpService
      .patch(url, body)
      .do((response: any) => {
        // do stuff
      })
      .catch(e => this.isError409(e));

AFTER

    return this.httpService
      .patch(url, body).pipe(
      tap((response: any) => {
       // do stuff
      }),
      catchError(e => this.isError409(e)),);

As you can see at the catchError line a , was added.

Another example is here:

BEFORE

  click$ = Observable.defer(() => Observable.fromEvent(this.ele.nativeElement, 'click'))
    .takeUntil(this.destroy$)
    .publish();

AFTER

  click$ = observableDefer(() => observableFromEvent(this.ele.nativeElement, 'click')).pipe(
    takeUntil(this.destroy$),
    publish(),);

Is this expected? Is there a CLI flag that i might have missed?

Thank you.

mgechev commented 6 years ago

Hey @ndcunningham, thanks for giving the tool a try! I'm happy you were able to migrate your app. The trailing comma is not an invalid syntax. As we've recommended in readme, after you run the migration tool, you can format your code with prettier or clang-format to make sure everything aligns with your coding style.