Skip to content

Possible false positive for no-cyclic-action #54

@jsaguet

Description

@jsaguet

The rule no-cyclic-action detects a problem in the below code.
However, since I'm using { dispatch: false } in createEffect, I am not sure the error should be raised.

Is there another way to write such an ngrx effect to comply with this rule or is this a false positive that could be fixed ?

effect$: Observable<Action> = createEffect(
    () =>
        this.actions$.pipe(
            ofType(myAction),
            tap(() => {
                this.service.showToast('Action was done');
            }),
        ),
    { dispatch: false },
);

Also, if I transform the above code into the following one to try to avoid this error, the lint process errors:

effect$: Observable<void> = createEffect(
    () =>
        this.actions$.pipe(
            ofType(myAction),
            map(() => this.service.showToast('Action was done')),
        ),
    { dispatch: false },
);
TypeError: Cannot read property 'valueDeclaration' of undefined
Occurred while linting ( line of this.actions$.pipe )
    at getActionTypes (node_modules\eslint-plugin-rxjs\dist\rules\no-cyclic-action.js:92:85)
    at checkNode (node_modules\eslint-plugin-rxjs\dist\rules\no-cyclic-action.js:72:37)
    at node_modules\eslint\lib\linter\safe-emitter.js:45:58
    at Array.forEach (<anonymous>)
    at Object.emit (node_modules\eslint\lib\linter\safe-emitter.js:45:38)
    at NodeEventGenerator.applySelector (node_modules\eslint\lib\linter\node-event-generator.js:254:26)
    at NodeEventGenerator.applySelectors (node_modules\eslint\lib\linter\node-event-generator.js:283:22)
    at NodeEventGenerator.enterNode (node_modules\eslint\lib\linter\node-event-generator.js:297:14)
    at CodePathAnalyzer.enterNode (node_modules\eslint\lib\linter\code-path-analysis\code-path-analyzer.js:711:23)
    at node_modules\eslint\lib\linter\linter.js:952:32

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions