From b7a0a7b931d8c3d05eaaeb7b4301aa2a06d642f4 Mon Sep 17 00:00:00 2001 From: Jason Weinzierl Date: Fri, 8 Nov 2024 10:57:51 -0600 Subject: [PATCH] test: remove mapTo in favor of map Remove mapTo from documentation and unit tests because it is deprecated by rxjs. Fixes upstream https://github.com/cartant/eslint-plugin-rxjs/pull/120 --- docs/rules/no-nested-subscribe.md | 4 +-- tests/rules/no-cyclic-action.test.ts | 50 ++++++++++++++-------------- 2 files changed, 27 insertions(+), 27 deletions(-) diff --git a/docs/rules/no-nested-subscribe.md b/docs/rules/no-nested-subscribe.md index 9a1ed6cc..cc948993 100644 --- a/docs/rules/no-nested-subscribe.md +++ b/docs/rules/no-nested-subscribe.md @@ -24,9 +24,9 @@ Examples of **correct** code for this rule: ```ts import { of, timer } from "rxjs"; -import { mapTo, mergeMap } from "rxjs/operators"; +import { map, mergeMap } from "rxjs/operators"; of(42, 54).pipe( - mergeMap((value) => timer(1e3).pipe(mapTo(value))) + mergeMap((value) => timer(1e3).pipe(map(() => value))) ).subscribe((value) => console.log(value)); ``` diff --git a/tests/rules/no-cyclic-action.test.ts b/tests/rules/no-cyclic-action.test.ts index 44b9b75a..d9d8ab6c 100644 --- a/tests/rules/no-cyclic-action.test.ts +++ b/tests/rules/no-cyclic-action.test.ts @@ -5,7 +5,7 @@ import { ruleTester } from '../rule-tester'; const setup = stripIndent` import { Observable, of } from "rxjs"; - import { mapTo } from "rxjs/operators"; + import { map } from "rxjs/operators"; type Action = { type: T }; type ActionOfType = T extends string ? Action : never; @@ -27,20 +27,20 @@ ruleTester({ types: true }).run('no-cyclic-action', noCyclicActionRule, { code: stripIndent` // effect SOMETHING to SOMETHING_ELSE ${setup} - const a = actions.pipe(ofType("SOMETHING"), mapTo({ type: "SOMETHING_ELSE" as const })); - const b = actions.pipe(ofType("SOMETHING"), mapTo({ type: SOMETHING_ELSE } as const)); - const c = actions.pipe(ofType(SOMETHING), mapTo({ type: "SOMETHING_ELSE" as const })); - const d = actions.pipe(ofType(SOMETHING), mapTo({ type: SOMETHING_ELSE } as const)); + const a = actions.pipe(ofType("SOMETHING"), map(() => ({ type: "SOMETHING_ELSE" as const }))); + const b = actions.pipe(ofType("SOMETHING"), map(() => ({ type: SOMETHING_ELSE }) as const)); + const c = actions.pipe(ofType(SOMETHING), map(() => ({ type: "SOMETHING_ELSE" as const }))); + const d = actions.pipe(ofType(SOMETHING), map(() => ({ type: SOMETHING_ELSE }) as const)); `, }, { code: stripIndent` // epic SOMETHING to SOMETHING_ELSE ${setup} - const a = (action$: Actions) => action$.pipe(ofType("SOMETHING"), mapTo({ type: "SOMETHING_ELSE" as const })); - const b = (action$: Actions) => action$.pipe(ofType("SOMETHING"), mapTo({ type: SOMETHING_ELSE } as const)); - const c = (action$: Actions) => action$.pipe(ofType(SOMETHING), mapTo({ type: "SOMETHING_ELSE" as const })); - const d = (action$: Actions) => action$.pipe(ofType(SOMETHING), mapTo({ type: SOMETHING_ELSE } as const)); + const a = (action$: Actions) => action$.pipe(ofType("SOMETHING"), map(() => ({ type: "SOMETHING_ELSE" as const }))); + const b = (action$: Actions) => action$.pipe(ofType("SOMETHING"), map(() => ({ type: SOMETHING_ELSE }) as const)); + const c = (action$: Actions) => action$.pipe(ofType(SOMETHING), map(() => ({ type: "SOMETHING_ELSE" as const }))); + const d = (action$: Actions) => action$.pipe(ofType(SOMETHING), map(() => ({ type: SOMETHING_ELSE }) as const)); `, }, { @@ -56,13 +56,13 @@ ruleTester({ types: true }).run('no-cyclic-action', noCyclicActionRule, { stripIndent` // effect SOMETHING to SOMETHING ${setup} - const a = actions.pipe(ofType("SOMETHING"), mapTo({ type: "SOMETHING" as const })); + const a = actions.pipe(ofType("SOMETHING"), map(() => ({ type: "SOMETHING" as const }))); ~~~~~~~~~~~~ [forbidden] - const b = actions.pipe(ofType("SOMETHING"), mapTo({ type: SOMETHING } as const)); + const b = actions.pipe(ofType("SOMETHING"), map(() => ({ type: SOMETHING }) as const)); ~~~~~~~~~~~~ [forbidden] - const c = actions.pipe(ofType(SOMETHING), mapTo({ type: "SOMETHING" as const })); + const c = actions.pipe(ofType(SOMETHING), map(() => ({ type: "SOMETHING" as const }))); ~~~~~~~~~~~~ [forbidden] - const d = actions.pipe(ofType(SOMETHING), mapTo({ type: SOMETHING } as const)); + const d = actions.pipe(ofType(SOMETHING), map(() => ({ type: SOMETHING }) as const)); ~~~~~~~~~~~~ [forbidden] `, ), @@ -70,13 +70,13 @@ ruleTester({ types: true }).run('no-cyclic-action', noCyclicActionRule, { stripIndent` // epic SOMETHING to SOMETHING ${setup} - const a = (action$: Actions) => action$.pipe(ofType("SOMETHING"), mapTo({ type: "SOMETHING" as const })); + const a = (action$: Actions) => action$.pipe(ofType("SOMETHING"), map(() => ({ type: "SOMETHING" as const }))); ~~~~~~~~~~~~ [forbidden] - const b = (action$: Actions) => action$.pipe(ofType("SOMETHING"), mapTo({ type: SOMETHING } as const)); + const b = (action$: Actions) => action$.pipe(ofType("SOMETHING"), map(() => ({ type: SOMETHING }) as const)); ~~~~~~~~~~~~ [forbidden] - const c = (action$: Actions) => action$.pipe(ofType(SOMETHING), mapTo({ type: "SOMETHING" as const })); + const c = (action$: Actions) => action$.pipe(ofType(SOMETHING), map(() => ({ type: "SOMETHING" as const }))); ~~~~~~~~~~~~ [forbidden] - const d = (action$: Actions) => action$.pipe(ofType(SOMETHING), mapTo({ type: SOMETHING } as const)); + const d = (action$: Actions) => action$.pipe(ofType(SOMETHING), map(() => ({ type: SOMETHING }) as const)); ~~~~~~~~~~~~ [forbidden] `, ), @@ -84,13 +84,13 @@ ruleTester({ types: true }).run('no-cyclic-action', noCyclicActionRule, { stripIndent` // effect SOMETHING | SOMETHING_ELSE to SOMETHING ${setup} - const a = actions.pipe(ofType("SOMETHING", "SOMETHING_ELSE"), mapTo({ type: "SOMETHING" as const })); + const a = actions.pipe(ofType("SOMETHING", "SOMETHING_ELSE"), map(() => ({ type: "SOMETHING" as const }))); ~~~~~~~~~~~~ [forbidden] - const b = actions.pipe(ofType("SOMETHING", "SOMETHING_ELSE"), mapTo({ type: SOMETHING } as const)); + const b = actions.pipe(ofType("SOMETHING", "SOMETHING_ELSE"), map(() => ({ type: SOMETHING }) as const)); ~~~~~~~~~~~~ [forbidden] - const c = actions.pipe(ofType(SOMETHING, SOMETHING_ELSE), mapTo({ type: "SOMETHING" as const })); + const c = actions.pipe(ofType(SOMETHING, SOMETHING_ELSE), map(() => ({ type: "SOMETHING" as const }))); ~~~~~~~~~~~~ [forbidden] - const d = actions.pipe(ofType(SOMETHING, SOMETHING_ELSE), mapTo({ type: SOMETHING } as const)); + const d = actions.pipe(ofType(SOMETHING, SOMETHING_ELSE), map(() => ({ type: SOMETHING }) as const)); ~~~~~~~~~~~~ [forbidden] `, ), @@ -98,13 +98,13 @@ ruleTester({ types: true }).run('no-cyclic-action', noCyclicActionRule, { stripIndent` // epic SOMETHING | SOMETHING_ELSE to SOMETHING ${setup} - const a = (action$: Actions) => action$.pipe(ofType("SOMETHING", "SOMETHING_ELSE"), mapTo({ type: "SOMETHING" as const })); + const a = (action$: Actions) => action$.pipe(ofType("SOMETHING", "SOMETHING_ELSE"), map(() => ({ type: "SOMETHING" as const }))); ~~~~~~~~~~~~ [forbidden] - const b = (action$: Actions) => action$.pipe(ofType("SOMETHING", "SOMETHING_ELSE"), mapTo({ type: SOMETHING } as const)); + const b = (action$: Actions) => action$.pipe(ofType("SOMETHING", "SOMETHING_ELSE"), map(() => ({ type: SOMETHING }) as const)); ~~~~~~~~~~~~ [forbidden] - const c = (action$: Actions) => action$.pipe(ofType(SOMETHING, SOMETHING_ELSE), mapTo({ type: "SOMETHING" as const })); + const c = (action$: Actions) => action$.pipe(ofType(SOMETHING, SOMETHING_ELSE), map(() => ({ type: "SOMETHING" as const }))); ~~~~~~~~~~~~ [forbidden] - const d = (action$: Actions) => action$.pipe(ofType(SOMETHING, SOMETHING_ELSE), mapTo({ type: SOMETHING } as const)); + const d = (action$: Actions) => action$.pipe(ofType(SOMETHING, SOMETHING_ELSE), map(() => ({ type: SOMETHING }) as const)); ~~~~~~~~~~~~ [forbidden] `, ),