cartant / eslint-plugin-rxjs

ESLint rules for RxJS
MIT License
312 stars 37 forks source link

rxjs-no-unsafe-takeuntil #98

Open splincode opened 2 years ago

splincode commented 2 years ago

Hello, could you help me? what am I doing wrong in this situation?

https://github.com/Tinkoff/taiga-ui/blob/main/projects/addon-mobile/directives/ripple/ripple.directive.ts#L103

taiga-ui kit have some code

start$
            .pipe(
                mergeMap(ripple => {
                    const animationEndOn$ = typedFromEvent(ripple, 'animationend');

                    return race(
                        timer(TOUCH_MOVE_DELAY).pipe(mapTo(false)),
                        touchEnd$.pipe(mapTo(true)),
                    ).pipe(
                        take(1),
                        takeUntil(touchMove$), // here
                        tap(() => {
                            renderer.setStyle(
                                ripple,
                                'background',
                                this.tuiRipple || null,
                            );
                            renderer.appendChild(nativeElement, ripple);
                        }),
                        switchMap(isTap =>
                            isTap
                                ? animationEndOn$
                                : race<unknown>(
                                      touchEnd$.pipe(switchMapTo(animationEndOn$)),
                                      animationEndOn$.pipe(switchMapTo(touchEnd$)),
                                  ),
                        ),
                        mapTo(ripple),
                    );
                }),
                takeUntil(destroy$),
            )

takeUntil(touchMove$)

but this line should not move, however the linter considers it an error, what should I do?

cathey191 commented 2 years ago

tap, switchMap and mapTo can come before but not after takeUntil. A list of what can be after takeUntil can be found here: https://github.com/cartant/eslint-plugin-rxjs/blob/main/source/rules/no-unsafe-takeuntil.ts