You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
constcreateInvokeMachine=()=>createMachine({/* ... */})constmachine=createMachine({invoke: {// error: [eslint xstate/invoke-usage] The` value of the "src" property in the "invoke" object must be a machine, function, string or an object.src: createInvokeMachine()},});
Expected behavior
Machine creation functions should be allowed as an argument to src.
Discussion
I am not sure how powerful ESlint is here - can it actually track that a creation function returns a machine, across imports? It seems like it won't be able to.
Maybe it's fine to allow the rule to accept a function call expression?
Versions (please complete the following information):
Node version: v14.17.3
ESLint version: 7.23.0
eslint-plugin-xstate version: 0.12.2
The text was updated successfully, but these errors were encountered:
I am not sure how powerful ESlint is here - can it actually track that a creation function returns a machine, across imports? It seems like it won't be able to.
That's right. Since this is a static code analysis tool (it builds an AST) ESlint does not execute functions to track down the return value.
The best we can do here is to allow functions as a src value. The message actually says functions are allowed so I'm going to check why this fails.
Function calls need to be allowed.
Describe the bug
Expected behavior
Machine creation functions should be allowed as an argument to
src
.Discussion
I am not sure how powerful ESlint is here - can it actually track that a creation function returns a machine, across imports? It seems like it won't be able to.
Maybe it's fine to allow the rule to accept a function call expression?
Versions (please complete the following information):
v14.17.3
7.23.0
0.12.2
The text was updated successfully, but these errors were encountered: