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

Wrong "xstate/no-imperative-action" inside actions.pure() #4

Closed
VanTanev opened this issue May 11, 2021 · 4 comments
Closed

Wrong "xstate/no-imperative-action" inside actions.pure() #4

VanTanev opened this issue May 11, 2021 · 4 comments
Labels
bug Something isn't working released

Comments

@VanTanev
Copy link
Contributor

Describe the bug
"xstate/no-imperative-action" is triggered with valid use of send()

Actual behavior

import { actions, send, createMachine } from 'xstate'

export const machine = createMachine<any, any>(
    {
        on: {
            EVENT: {
                actions: actions.pure(() => {
                    return [
                      // getting eslint xstate/no-imperative-action
                      send({ type: 'BLAH' })
                    ]
                }),
            },
        },
    },
)

Versions (please complete the following information):

  • Node version :v14.15.5
  • ESLint version: eslint@7.23.0
  • eslint-plugin-xstate version: eslint-plugin-xstate@0.8.0

Additional context
If I use actions.send() it works, but I think that's because the eslint plugin doesn't actually execute in that case?

@VanTanev VanTanev added the bug Something isn't working label May 11, 2021
@rlaffers
Copy link
Owner

Thanks for the report. Definitely looks like a bug.

@rlaffers
Copy link
Owner

It is detected as a violation, because actions.pure is not recognized as THE pure action creator (which is the only context in which calling other action creators is sensible). I will add "actions.pure" into the list to allow for this usage.

@rlaffers
Copy link
Owner

🎉 This issue has been resolved in version 0.10.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

@VanTanev
Copy link
Contributor Author

Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working released
Projects
None yet
Development

No branches or pull requests

2 participants