@@ -18,6 +18,20 @@ Certain properties accept specific values only:
18
18
- ` type ` can be one of: "atomic", "compound", "parallel", "history", "final".
19
19
- ` history ` can be one of: "shallow", "deep".
20
20
21
+ ### XState v5
22
+
23
+ In XState v5 some props are no longer valid on state nodes:
24
+
25
+ - ` activities `
26
+ - ` data ` : removed in favor of a new prop ` output `
27
+ - ` strict `
28
+ - ` schema ` : removed in favor of a new prop ` types `
29
+ - ` tsTypes ` : removed in favor of a new prop ` types `
30
+ - ` preserveActionOrder `
31
+ - ` predictableActionArguments `
32
+
33
+ If the above props are used with XState v5, this rule will report an error.
34
+
21
35
Examples of ** incorrect** code for this rule:
22
36
23
37
``` javascript
@@ -71,13 +85,61 @@ createMachine({
71
85
Examples of ** correct** code for this rule:
72
86
73
87
``` javascript
74
- // ✅ all state props are valid
88
+ // ✅ all state props are valid (XState v4)
75
89
createMachine ({
76
90
id: ' root' ,
91
+ strict: true ,
77
92
description: ' this is the main machine' ,
78
93
predictableActionArguments: true ,
94
+ preserveActionOrder: true ,
95
+ tsTypes: {},
96
+ schema: {},
97
+ context: {}, // valid in the root node
98
+ initial: ' idle' ,
99
+ states: {
100
+ idle: {
101
+ type: ' parallel' ,
102
+ entry: ' log' ,
103
+ exit: ' log' ,
104
+ always: [],
105
+ after: {},
106
+ states: {},
107
+ onDone: {},
108
+ on: {},
109
+ tags: [' off' ],
110
+ activities: [' beeping' ],
111
+ },
112
+ busy: {
113
+ type: ' compound' ,
114
+ initial: ' reading' ,
115
+ states: {
116
+ hist: {
117
+ type: ' history' ,
118
+ history: ' deep' ,
119
+ target: ' writing' ,
120
+ },
121
+ reading: {
122
+ meta: {
123
+ value: 42 ,
124
+ },
125
+ },
126
+ writing: {},
127
+ },
128
+ },
129
+ done: {
130
+ type: ' final' ,
131
+ data: { answer: 42 },
132
+ },
133
+ },
134
+ })
135
+
136
+ // ✅ all state props are valid (XState v5)
137
+ createMachine ({
138
+ id: ' root' ,
139
+ types: {},
140
+ description: ' this is the main machine' ,
79
141
context: {}, // valid in the root node
80
- initial: ' idle'
142
+ initial: ' idle' ,
81
143
states: {
82
144
idle: {
83
145
type: ' parallel' ,
@@ -107,6 +169,10 @@ createMachine({
107
169
writing: {},
108
170
},
109
171
},
172
+ done: {
173
+ type: ' final' ,
174
+ output: { answer: 42 },
175
+ },
110
176
},
111
177
})
112
178
```
0 commit comments