File tree Expand file tree Collapse file tree 1 file changed +16
-2
lines changed Expand file tree Collapse file tree 1 file changed +16
-2
lines changed Original file line number Diff line number Diff line change @@ -20,12 +20,14 @@ module.exports = {
20
20
invalidSystemId : 'Property "systemId" should be a non-empty string.' ,
21
21
systemIdNotAllowedBeforeVersion5 :
22
22
'Property "systemId" is not supported in xstate < 5.' ,
23
+ duplicateSystemId : 'The systemId "{{systemId}}" is not unique.' ,
23
24
} ,
24
25
} ,
25
26
26
27
create ( context ) {
27
28
const { version } = getSettings ( context )
28
29
const prefix = getSelectorPrefix ( context . sourceCode )
30
+ const systemIds = new Set ( )
29
31
30
32
return {
31
33
[ `${ prefix } Property[key.name='invoke'] > ObjectExpression` ] : ( node ) => {
@@ -79,8 +81,20 @@ module.exports = {
79
81
}
80
82
} ,
81
83
82
- // TODO another check should make sure that the systemId is unique
83
- // code here
84
+ [ `${ prefix } Property[key.name='invoke'] > ObjectExpression > Property[key.name="systemId"]` ] :
85
+ ( node ) => {
86
+ if ( systemIds . has ( node . value . value ) ) {
87
+ context . report ( {
88
+ node,
89
+ messageId : 'duplicateSystemId' ,
90
+ data : { systemId : node . value . value } ,
91
+ } )
92
+ } else {
93
+ systemIds . add ( node . value . value )
94
+ }
95
+ } ,
96
+
97
+ // TODO check use of systemId in spawns
84
98
}
85
99
} ,
86
100
}
You can’t perform that action at this time.
0 commit comments