Skip to content

Commit

Permalink
test: remove mapTo in favor of map
Browse files Browse the repository at this point in the history
Remove mapTo from documentation and unit tests because it is deprecated by rxjs.

Fixes upstream cartant#120
  • Loading branch information
JasonWeinzierl committed Nov 8, 2024
1 parent bb05898 commit b7a0a7b
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 27 deletions.
4 changes: 2 additions & 2 deletions docs/rules/no-nested-subscribe.md
Original file line number Diff line number Diff line change
Expand Up @@ -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));
```
50 changes: 25 additions & 25 deletions tests/rules/no-cyclic-action.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<T extends string> = { type: T };
type ActionOfType<T> = T extends string ? Action<T> : never;
Expand All @@ -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));
`,
},
{
Expand All @@ -56,55 +56,55 @@ 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]
`,
),
fromFixture(
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]
`,
),
fromFixture(
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]
`,
),
fromFixture(
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]
`,
),
Expand Down

0 comments on commit b7a0a7b

Please sign in to comment.