ngrx / platform

Reactive State for Angular
https://ngrx.io
Other
8.01k stars 1.97k forks source link

fix(eslint-plugin): do not report non-array returns in no-multiple-actions-in-effects #4418

Closed jsaguet closed 2 months ago

jsaguet commented 3 months ago

…tions-in-effects

PR Checklist

Please check if your PR fulfills the following requirements:

PR Type

What kind of change does this PR introduce?

[x] Bugfix
[ ] Feature
[ ] Code style update (formatting, local variables)
[ ] Refactoring (no functional changes, no api changes)
[ ] Build related changes
[ ] CI related changes
[ ] Documentation content changes
[ ] Other... Please describe:

What is the current behavior?

Eslint rules incorrectly reports an error for the rule no-multiple-actions-in-effects for the following code:

import { Actions, createEffect, ofType } from '@ngrx/effects';
import { createAction, props } from '@ngrx/store';
import { of, switchMap } from 'rxjs';

const foo = createAction('foo', props<{ payload: string }>());
const bar = createAction('bar');
const baz = createAction('baz');

@Injectable()
export class Effects {
  constructor(private actions$: Actions) {}
  effect$ = createEffect(() =>
      this.actions$.pipe(
          ofType(foo),
          switchMap(({ payload }: { payload: string }) => (payload === 'value' ? of(bar()) : of(baz()))),
      ),
  );
}

Closes #

What is the new behavior?

The eslint rule does not report an error on the valid code.

Does this PR introduce a breaking change?

[ ] Yes
[x] No

Other information

netlify[bot] commented 3 months ago

Deploy Preview for ngrx-io canceled.

Built without sensitive environment variables

Name Link
Latest commit 1d6069f9a43b315caab4962d56d0a7ef48b471d1
Latest deploy log https://app.netlify.com/sites/ngrx-io/deploys/6686b7c00674b200081b438e
markostanimirovic commented 2 months ago

Thank you @jsaguet!