eslint-plugin-rxjs icon indicating copy to clipboard operation
eslint-plugin-rxjs copied to clipboard

rxjs-no-unsafe-takeuntil

Open splincode opened this issue 2 years ago • 1 comments

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?

splincode avatar Apr 08 '22 07:04 splincode

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

cathey191 avatar Apr 10 '22 20:04 cathey191