Git Product home page Git Product logo

Comments (6)

gcazaciuc avatar gcazaciuc commented on August 21, 2024 3

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.

pke avatar pke commented on August 21, 2024 1

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.

SpainTrain avatar SpainTrain commented on August 21, 2024

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.

SpainTrain avatar SpainTrain commented on August 21, 2024

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.

pke avatar pke commented on August 21, 2024

Sure, this makes sense and sends easy to fix. I'm in holidays now but PR welcome

from eslint-plugin-redux-saga.

pke avatar pke commented on August 21, 2024

Please check the new 0.7.0 if it fixes your issue.

from eslint-plugin-redux-saga.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.