davesnx/babel-plugin-transform-react-qa-classes

`Cannot read property 'name' of undefined`

vjpr opened this issue ยท 8 comments

vjpr commented
TypeError: xxx/packages/flow-runtime-utils/flow-runtime-custom-message.js: Cannot read property 'name' of undefined
    at PluginPass.ArrowFunctionExpression (xxx/node_modules/.registry.npmjs.org/babel-plugin-transform-react-qa-classes/0.0.5/node_modules/babel-plugin-transform-react-qa-classes/lib/index.js:14:44)
    at newFn (xxx/node_modules/.registry.npmjs.org/babel-traverse/6.26.0/node_modules/babel-traverse/lib/visitors.js:276:21)
    at NodePath._call (xxx/node_modules/.registry.npmjs.org/babel-traverse/6.26.0/node_modules/babel-traverse/lib/path/context.js:76:18)
    at NodePath.call (xxx/node_modules/.registry.npmjs.org/babel-traverse/6.26.0/node_modules/babel-traverse/lib/path/context.js:48:17)
    at NodePath.visit (xxx/node_modules/.registry.npmjs.org/babel-traverse/6.26.0/node_modules/babel-traverse/lib/path/context.js:105:12)
    at TraversalContext.visitQueue (xxx/node_modules/.registry.npmjs.org/babel-traverse/6.26.0/node_modules/babel-traverse/lib/context.js:150:16)
    at TraversalContext.visitSingle (xxx/node_modules/.registry.npmjs.org/babel-traverse/6.26.0/node_modules/babel-traverse/lib/context.js:108:19)
    at TraversalContext.visit (xxx/node_modules/.registry.npmjs.org/babel-traverse/6.26.0/node_modules/babel-traverse/lib/context.js:192:19)
    at Function.traverse.node (xxx/node_modules/.registry.npmjs.org/babel-traverse/6.26.0/node_modules/babel-traverse/lib/index.js:114:17)
    at NodePath.visit (xxx/node_modules/.registry.npmjs.org/babel-traverse/6.26.0/node_modules/babel-traverse/lib/path/context.js:115:19)

Hey @vjpr

Thanks for pointing this out, I will take a look

Hey @vjpr

I published version 0.0.6 and I had a fix for this error. I assume that this was caused on an arrow component without a parent, I'm avoiding adding the data-qa on those cases.

Hope that it helps and sorry for being so late!

Hey @davesnx I can't see version 0.0.6. Did you publish?

@davesnx It's been a little while; are you going to publish another version to NPM? Right now we can only install v0.0.5 of this package from an npm install command.

Btw should you only be checking for path.parent and exiting? It's a very normal thing for there to be a parent, but no id. That'll cause your next line of this to fail:

if (!path.parent) return
const componentName = path.parent.id.name

Someone who forked your package (but also didn't publish it to NPM ๐Ÿ‘Ž ) seems to have gone that route:

if (!path.parent.id || !path.parent.id.name) return
const componentName = path.parent.id.name

Also was this intentional?

....
import snakeCase from 'lodash.snakecase'

const langTransforms = {
....
  snake: kebabCase
}

Hey @davesnx I can't see version 0.0.6. Did you publish?

It was blocked by #10

I just published 1.0.0 version.

Apologies for being very disconnected about this project. I fixed both comments from @arizonatribe.