Skip to content

Commit

Permalink
fix(no-inline-implementation): detect inline implementations inside c…
Browse files Browse the repository at this point in the history
…hoose action creator
  • Loading branch information
rlaffers committed May 12, 2021
1 parent 2891ee1 commit 8f8b9d3
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions lib/rules/no-inline-implementation.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,12 @@ const propertyOfOnDoneOnErrorTransitionInArray =
const activitiesProperty =
'CallExpression[callee.name=/^createMachine$|^Machine$/] Property[key.name="activities"]'

const propertyOfChoosableActionObject =
'CallExpression[callee.name=/^createMachine$|^Machine$/] CallExpression[callee.name="choose"] > ArrayExpression > ObjectExpression > Property'

const propertyOfChoosableActionObjectAlt =
'CallExpression[callee.name=/^createMachine$|^Machine$/] CallExpression[callee.type="MemberExpression"][callee.object.name="actions"][callee.property.name="choose"] > ArrayExpression > ObjectExpression > Property'

const defaultOptions = {
allowKnownActionCreators: false,
}
Expand Down Expand Up @@ -161,6 +167,8 @@ module.exports = {
[propertyOfAltEventTransitionInArray]: checkTransitionProperty,
[propertyOfOnDoneOnErrorTransition]: checkTransitionProperty,
[propertyOfOnDoneOnErrorTransitionInArray]: checkTransitionProperty,
[propertyOfChoosableActionObject]: checkTransitionProperty,
[propertyOfChoosableActionObjectAlt]: checkTransitionProperty,

[activitiesProperty]: function (node) {
if (
Expand Down

0 comments on commit 8f8b9d3

Please sign in to comment.