Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incorrect behavior of @ngrx/avoid-mapping-selectors lint rule #3511

Closed
1 of 2 tasks
yurakhomitsky opened this issue Aug 4, 2022 · 2 comments · Fixed by #3546
Closed
1 of 2 tasks

Incorrect behavior of @ngrx/avoid-mapping-selectors lint rule #3511

yurakhomitsky opened this issue Aug 4, 2022 · 2 comments · Fixed by #3546

Comments

@yurakhomitsky
Copy link

yurakhomitsky commented Aug 4, 2022

Minimal reproduction of the bug/regression with instructions

image

Minimal reproduction of the bug/regression with instructions

  1. install ngrx-eslint-plugin: "@ngrx/eslint-plugin": "^14.0.2",
  2. add to eslint config : extends: ['plugin:@ngrx/recommended'],
  3. Use this.store.select(selector).pipe(switchMap, map)
  4. Note warning

Expected behavior there should not be a warning if there is an operator that changes the stream before the map

Versions of NgRx, Angular, Node, affected browser(s) and operating system(s)

Ngrx: 13.1.0
Angular: 13.3.2
Node: 16.15.0

Other information

No response

I would be willing to submit a PR to fix this issue

  • Yes
  • No
@timdeschryver
Copy link
Member

timdeschryver commented Aug 5, 2022

Could you elaborate this use case a bit more please?
In the snippet shown, the map that's giving the error isn't doing anything with the selector's result, so I would move it to the map logic of the switchMap.

@yurakhomitsky
Copy link
Author

@timdeschryver, sorry for the lousy screenshot, here is another one.
In my case, the map logic could be moved to switchMap's map.

However what if the logic in the switchMap's map would be hard to read and I would want to move it to a separate map

I was thinking about whether it is possible to not show a warning if there is a switchMap/mergeMap before the map operator in the store selector pipe chain.

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants