Skip to content

Cannot perform object spread inside of a race object #69

Open
@noahnu

Description

@noahnu

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions