eslint-plugin-xstate
Advanced tools
Comparing version 1.1.1 to 1.1.2
@@ -41,2 +41,3 @@ 'use strict' | ||
'entry', | ||
'exit', | ||
'history', // only when type=history | ||
@@ -43,0 +44,0 @@ 'id', |
@@ -7,12 +7,23 @@ 'use strict' | ||
function isWithinAtomicStateNode(node) { | ||
function isWithinCompoundStateNode(node) { | ||
const stateNode = node.parent | ||
const type = getTypeProperty(stateNode) | ||
return ( | ||
!isWithinInvoke(node) && | ||
((type != null && type.value.value === 'atomic') || | ||
(type == null && !hasProperty('initial', stateNode))) | ||
hasProperty('initial', stateNode) || | ||
(type != null && type.value.value === 'compound') | ||
) | ||
} | ||
function isWithinParallelStateNode(node) { | ||
const stateNode = node.parent | ||
const type = getTypeProperty(stateNode) | ||
return type != null && type.value.value === 'parallel' | ||
} | ||
function isWithinAtomicStateNode(node) { | ||
const stateNode = node.parent | ||
const type = getTypeProperty(stateNode) | ||
return type != null && type.value.value === 'atomic' | ||
} | ||
function isWithinHistoryStateNode(node) { | ||
@@ -48,2 +59,4 @@ const stateNode = node.parent | ||
'Final state nodes cannot have an "onDone" transition. The "onDone" transition has effect only in compound/parallel state nodes or in service invocations.', | ||
onDoneUsedIncorrectly: | ||
'The "onDone" transition cannot be used here. The "onDone" transition has effect only in compound/parallel state nodes or in service invocations.', | ||
}, | ||
@@ -56,2 +69,11 @@ }, | ||
function (node) { | ||
if (isWithinInvoke(node)) { | ||
return | ||
} | ||
if (isWithinCompoundStateNode(node)) { | ||
return | ||
} | ||
if (isWithinParallelStateNode(node)) { | ||
return | ||
} | ||
if (isWithinAtomicStateNode(node)) { | ||
@@ -76,3 +98,8 @@ context.report({ | ||
}) | ||
return | ||
} | ||
context.report({ | ||
node, | ||
messageId: 'onDoneUsedIncorrectly', | ||
}) | ||
}, | ||
@@ -79,0 +106,0 @@ } |
@@ -108,3 +108,15 @@ const { allPass, complement } = require('./combinators') | ||
const parentProp = property.parent.parent | ||
return parentProp.type === 'Property' && parentProp.key.name === 'invoke' | ||
if ( | ||
parentProp && | ||
parentProp.type === 'Property' && | ||
parentProp.key.name === 'invoke' | ||
) { | ||
return true | ||
} | ||
return ( | ||
parentProp.type === 'ArrayExpression' && | ||
parentProp.parent && | ||
parentProp.parent.type === 'Property' && | ||
parentProp.parent.key.name === 'invoke' | ||
) | ||
} | ||
@@ -111,0 +123,0 @@ |
{ | ||
"name": "eslint-plugin-xstate", | ||
"version": "1.1.1", | ||
"version": "1.1.2", | ||
"description": "ESLint rules for XState", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
83947
2253