Comments (6)
Having the same problem. In my opinion doesn't make sense to do this validation if the effect is not invoked within a generator function since it that case doesn't make sense to yield anything. A simple check to see if the enclosing function is actually a generator should do the trick.
from eslint-plugin-redux-saga.
Good question. Its kind of hard to support every test framework out there, so I guess for now the best option you have is to disable the rule in tests.
from eslint-plugin-redux-saga.
I will add that this causes false positives for both yield-effects
and no-unhandled-errors
.
@gcazaciuc's suggestion to check that enclosing function is a generator would prevent 100% of our false positives.
If this solution is acceptable, could open a PR.
from eslint-plugin-redux-saga.
Here is another example (not in test code) of a false positive yield-effects
that would be prevented by checking that wrapping block is a generator function
/* eslint-disable redux-saga/yield-effects */
const mapContextToLoadEffect = cond([
[matches({currentUserRole: SELLER_ROLE}), constant(call(getAllSellerInfoSaga))],
[matches({currentUserRole: BUYER_ROLE}), constant(call(getAllBuyerInfoSaga))],
[constant(true), constant(call(noop))],
])
/* eslint-enable redux-saga/yield-effects */
const GET_ALL_CURRENT_USER_INFO = 'hz-webapp/current-user/GET_ALL_CURRENT_USER_INFO'
export const getAllCurrentUserInfo = createAction(GET_ALL_CURRENT_USER_INFO)
export function* getAllCurrentUserInfoSaga() {
const context = {
currentUserRole: yield select(currentUserRoleSelector),
}
yield mapContextToLoadEffect(context)
}
from eslint-plugin-redux-saga.
Sure, this makes sense and sends easy to fix. I'm in holidays now but PR welcome
from eslint-plugin-redux-saga.
Please check the new 0.7.0 if it fixes your issue.
from eslint-plugin-redux-saga.
Related Issues (20)
- catch `put(function*)`
- yield-effects - delegate yield* expression HOT 3
- Unnecessary strict dependency? HOT 4
- Allow effects to be used without yield in arrays HOT 3
- no-unhandled-error expects try-catch around effects that can't be caught HOT 6
- Version 10 of node.js has been released HOT 1
- no-yield-in-race handle arrays HOT 2
- False positive for rule no-yield-in-race when Array.map() is used inside race() HOT 1
- Please update to latest version of redux-saga HOT 1
- Release notes HOT 2
- Peer dependency warning HOT 5
- Enforce usage of selector functions on state in sagas HOT 2
- No unhandled errors error thrown when using `takeLeading` HOT 6
- Cannot perform object spread inside of a race object HOT 4
- yield-effects autofix modifies code functionality violating eslint best practices HOT 1
- Add yield-effects rule support for using `all` with a variable HOT 6
- Provide support for eslint 8 HOT 2
- Allow `return` of effects using `yield-effects` rule? HOT 4
- Rule proposal: Ensure yield on call to generator function HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from eslint-plugin-redux-saga.