Skip to content

Commit 0c16c1b

Browse files
committed
add some guards
1 parent bc53627 commit 0c16c1b

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

src/visitors/displayNameAndId.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ const addConfig = t => (path, displayName, componentId) => {
4444
if (
4545
existingConfig &&
4646
existingConfig.arguments.length &&
47+
Array.isArray(existingConfig.arguments[0].properties) &&
4748
!existingConfig.arguments[0].properties.some(prop =>
4849
['displayName', 'componentId'].includes(prop.key.name)
4950
)
@@ -59,6 +60,7 @@ const addConfig = t => (path, displayName, componentId) => {
5960
path.node.callee.callee.property.name &&
6061
path.node.callee.callee.property.name == 'withConfig' &&
6162
path.node.callee.arguments.length &&
63+
Array.isArray(path.node.callee.arguments[0].properties) &&
6264
!path.node.callee.arguments[0].properties.some(prop =>
6365
['displayName', 'componentId'].includes(prop.key.name)
6466
)
@@ -216,6 +218,8 @@ export default t => (path, state) => {
216218
path.node.callee.callee.property &&
217219
path.node.callee.callee.property.name &&
218220
path.node.callee.callee.property.name === 'withConfig' &&
221+
path.node.callee.arguments.length &&
222+
Array.isArray(path.node.callee.arguments[0].properties) &&
219223
!path.node.callee.arguments[0].properties.some(prop =>
220224
['displayName', 'componentId'].includes(prop.key.name)
221225
))

0 commit comments

Comments
 (0)