Suggest using the new always
syntax for declaring transient (a.k.a. eventless) transitions instead of the deprecated empty string syntax.
XState v4.11+ provides a new always
syntax for declaring transient transitions, now called eventless transitions. The empty string syntax will be deprecated in v5.
Examples of incorrect code for this rule:
// ❌ transient transition declared with an empty string
createMachine({
states: {
playing: {
on: {
'': [
{ target: 'win', cond: 'didPlayerWin' },
{ target: 'lose', cond: 'didPlayerLose' },
],
},
},
},
})
Examples of correct code for this rule:
// ✅ using the new "always" syntax
createMachine({
states: {
playing: {
always: [
{ target: 'win', cond: 'didPlayerWin' },
{ target: 'lose', cond: 'didPlayerLose' },
],
},
},
})