import traverse from '@babel/traverse' ; import * as t from '@babel/types' ; export const getFunctionArgs = ( functionName , memberExpression ) : t . CallExpression [ 'arguments' ] => { const identifierOpts = { name : functionName } ; let args = [ ] ; traverse ( memberExpression , { noScope : true , CallExpression ( path ) { const { node } = path ; const { callee } = node ; const found = t . isIdentifier ( callee , identifierOpts ) || ( t . isMemberExpression ( callee ) && t . isIdentifier ( callee . property , identifierOpts ) ) ; if ( found ) { args = node . arguments ; path . stop ( ) ; } } , } ) ; return args ; } ;