Skip to content

Commit 92a68bc

Browse files
authoredJul 9, 2024··
fix(eslint-plugin): do not report non-array returns in no-multiple-actions-in-effects (#4418)
1 parent 377f3b8 commit 92a68bc

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed
 

Diff for: ‎modules/eslint-plugin/spec/rules/effects/no-multiple-actions-in-effects.spec.ts

+18
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,24 @@ export const saveSearchCriteria$ = createEffect(
9494
{ functional: true }
9595
);
9696
`,
97+
`
98+
import { Actions, createEffect, ofType } from '@ngrx/effects';
99+
import { createAction, props } from '@ngrx/store';
100+
import { of, switchMap } from 'rxjs';
101+
const foo = createAction('foo', props<{ payload: string }>());
102+
const bar = createAction('bar');
103+
const baz = createAction('baz');
104+
105+
@Injectable()
106+
export class Effects {
107+
constructor(private actions$: Actions) {}
108+
effect$ = createEffect(() =>
109+
this.actions$.pipe(
110+
ofType(foo),
111+
switchMap(({ payload }: { payload: string }) => (payload === 'value' ? of(bar()) : of(baz()))),
112+
),
113+
);
114+
}`,
97115
];
98116

99117
const invalid: () => RunTests['invalid'] = () => [

Diff for: ‎modules/eslint-plugin/src/rules/effects/no-multiple-actions-in-effects.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ export default createRule<Options, MessageIds>({
5858
});
5959
} else if (
6060
type.isUnion() &&
61-
type.types.some((ut) => !typeChecker.isArrayType(ut))
61+
type.types.some((ut) => typeChecker.isArrayType(ut))
6262
) {
6363
context.report({
6464
node: nodeToReport,

0 commit comments

Comments
 (0)
Please sign in to comment.