File tree Expand file tree Collapse file tree 2 files changed +4
-6
lines changed
Expand file tree Collapse file tree 2 files changed +4
-6
lines changed Original file line number Diff line number Diff line change 11{
22 "name" : " babel-plugin-transform-react-qa-classes" ,
3- "version" : " semantic-release " ,
3+ "version" : " 0.0.6 " ,
44 "description" : " Add component's name in `data-qa` attributes to React Components Edit" ,
55 "repository" : " https://github.com/davesnx/babel-plugin-transform-react-qa-classes" ,
66 "author" : " davesnx <dsnxmoreno@gmail.com>" ,
Original file line number Diff line number Diff line change @@ -5,13 +5,11 @@ export default function ({types: t}) {
55 visitor : {
66 ArrowFunctionExpression ( path , state ) {
77 const options = checkValidOptions ( state )
8+ if ( ! path . parent ) return
89 const componentName = path . parent . id . name
910
1011 const functionBody = path . get ( 'body' ) . get ( 'body' )
11- const returnStatement = functionBody . find ( ( c ) => {
12- return c . type === 'ReturnStatement'
13- } )
14-
12+ const returnStatement = functionBody . find ( ( c ) => c . type === 'ReturnStatement' )
1513 const arg = returnStatement . get ( 'argument' )
1614 if ( ! arg . isJSXElement ( ) ) return
1715
@@ -49,7 +47,7 @@ export default function ({types: t}) {
4947 openingElement . node . attributes . push (
5048 t . jSXAttribute (
5149 t . jSXIdentifier ( options . attribute ) ,
52- t . stringLiteral ( options . format ( name . node . name ) )
50+ t . stringLiteral ( options . format ( name . node && name . node . name ) )
5351 )
5452 )
5553 }
You can’t perform that action at this time.
0 commit comments