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

Cannot perform object spread inside of a race object #69

Open
noahnu opened this issue Mar 25, 2020 · 4 comments
Open

Cannot perform object spread inside of a race object #69

noahnu opened this issue Mar 25, 2020 · 4 comments
Labels

Comments

@noahnu
Copy link

noahnu commented Mar 25, 2020

Given

import { race, take } from 'redux-saga/effects'

function* saga() {
    const waitEffects = {
        success: take(SomeSuccessAction),
        failure: take(SomeFailureAction),
    }
    
    yield race({
        ...waitEffects,
        other: take(otherAction),
    })
}

Running eslint with the above results in:

TypeError: Cannot read property 'name' of undefined
Occurred while linting /Users/noah/test-saga.js:9
at checkYieldInObject (/Users/noah/node_modules/eslint-plugin-redux-saga/lib/rules/no-yield-in-race.js:11:29)
at CallExpression (/Users/noah/node_modules/eslint-plugin-redux-saga/lib/rules/no-yield-in-race.js:81:13)
at /Users/noah/node_modules/eslint/lib/linter/safe-emitter.js:45:58

This happens in the "no yield in race" rule. In checkYieldInObject, it assumes each property has a "key". The ExperimentalSpreadProperty node does not have a key.

If it's not reasonable to lookup the referenced object, a warning should be reported that object spread is not supported.

@pke
Copy link
Owner

pke commented Mar 26, 2020

Thanks for reporting. I'll see when I have time to fix it.
I think it depends where the spread object is defined. The rule would have to lookup the definition, which static code analyse can not do (so easily). Because the object could be defined in another module and imported into the linted file.

@pke pke added the bug label Aug 16, 2020
@pke
Copy link
Owner

pke commented Aug 16, 2020

Sorry @noahnu I did not have time to tackle this yet and I am not sure when I will be able to.

@Nantris
Copy link

Nantris commented Apr 22, 2023

@pke can you suggest any workaround? Adding // eslint-disable-next-line redux-saga/no-yield-in-race has no effect - and then the only other possibility is to disable it for the whole file.

@Nantris
Copy link

Nantris commented Apr 22, 2023

I found no workaround without patching the rule. I submitted PR #82 .

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

No branches or pull requests

3 participants