(node, targetName)
| 89 | } |
| 90 | |
| 91 | function getDefinePropertyCallName(node, targetName) { |
| 92 | const { |
| 93 | callee: { object, property } |
| 94 | } = node; |
| 95 | if (!object || object.type !== 'Identifier' || object.name !== 'Object') return; |
| 96 | if (!property || property.type !== 'Identifier' || property.name !== 'defineProperty') return; |
| 97 | if (node.arguments.length !== 3) return; |
| 98 | |
| 99 | const targetNames = targetName.split('.'); |
| 100 | const [target, key, value] = node.arguments; |
| 101 | if (targetNames.length === 1) { |
| 102 | if (target.type !== 'Identifier' || target.name !== targetNames[0]) { |
| 103 | return; |
| 104 | } |
| 105 | } |
| 106 | |
| 107 | if (targetNames.length === 2) { |
| 108 | if ( |
| 109 | target.type !== 'MemberExpression' || |
| 110 | target.object.name !== targetNames[0] || |
| 111 | target.property.name !== targetNames[1] |
| 112 | ) { |
| 113 | return; |
| 114 | } |
| 115 | } |
| 116 | |
| 117 | if (value.type !== 'ObjectExpression' || !value.properties) return; |
| 118 | |
| 119 | const valueProperty = value.properties.find((p) => p.key && p.key.name === 'value'); |
| 120 | if (!valueProperty || !valueProperty.value) return; |
| 121 | |
| 122 | // eslint-disable-next-line consistent-return |
| 123 | return { key: key.value, value: valueProperty.value }; |
| 124 | } |
| 125 | |
| 126 | export function isShorthandProperty(parent) { |
| 127 | return parent && parent.type === 'Property' && parent.shorthand; |
no outgoing calls
no test coverage detected