rlaffers / eslint-plugin-xstate

ESLint plugin to check for common mistakes and enforce good practices when using XState.
MIT License
48 stars 4 forks source link

Support for XState v5 `guard` transition property #27

Closed ts-candide closed 9 months ago

ts-candide commented 10 months ago

Describe the bug

XState v5 has renamed the cond property to guard for guarded transitions. This plugin reports guard as an invalid transition property when placed inside an invoke.onDone array.

Expected behavior

No error when using guard as a transition property inside an invoke.onDone array.

Actual behavior

An ESLint error is shown when using guard as a transition property inside an invoke.onDone array.

Versions (please complete the following information):

Additional context

Here is some sample machine config:

{
  states: {
    selectingReader: {
      invoke: {
        src: "startDiscoveringReaders",
        onDone: [
          {
            guard: "noReadersDiscovered",
            target: "noReadersFound",
          },
        ],
        onError: "errored",
      },
    }
  }
}

The guard property is being marked as invalid here.

Screenshot 2023-12-07 at 14 43 16
rlaffers commented 10 months ago

Thanks for the report, I will look at it soon (ish).

rlaffers commented 9 months ago

@ts-candide The version you are using is not compatible with xstate v5. Please use eslint-plugin-xstate@next.

rlaffers commented 9 months ago

Version 3.2.1 of this plugin now supports xstate v5.