11import checkValidOptions from './options'
22import TaggedTemplateExpression from './styled-components'
33
4- function isReactFragment ( openingElement ) {
4+ function isReactFragment ( openingElement ) {
55 return (
66 openingElement . node . name . name === 'Fragment' ||
77 ( openingElement . node . name . type === 'JSXMemberExpression' &&
88 openingElement . node . name . object . name === 'React' &&
99 openingElement . node . name . property . name === 'Fragment' )
10- ) ;
10+ )
1111}
1212
13- function functionBodyPushAttributes ( t , path , options , componentName ) {
13+ function functionBodyPushAttributes ( t , path , options , componentName ) {
1414 let openingElement = null
1515 const functionBody = path . get ( 'body' ) . get ( 'body' )
1616 if ( functionBody . parent && functionBody . parent . type === 'JSXElement' ) {
17- const jsxElement = functionBody . find ( ( c ) => {
17+ const jsxElement = functionBody . find ( c => {
1818 return c . type === 'JSXElement'
1919 } )
2020 if ( ! jsxElement ) return
2121 openingElement = jsxElement . get ( 'openingElement' )
2222 } else {
23- const returnStatement = functionBody . find ( ( c ) => {
23+ const returnStatement = functionBody . find ( c => {
2424 return c . type === 'ReturnStatement'
2525 } )
2626 if ( ! returnStatement ) return
@@ -42,30 +42,30 @@ function functionBodyPushAttributes (t, path, options, componentName) {
4242 )
4343}
4444
45- export default function ( { types : t } ) {
45+ export default function ( { types : t } ) {
4646 return {
4747 visitor : {
4848 TaggedTemplateExpression,
49- FunctionDeclaration ( path , state ) {
50- if ( ! path . node . id || ! path . node . id . name ) return ;
49+ FunctionDeclaration ( path , state ) {
50+ if ( ! path . node . id || ! path . node . id . name ) return
5151
5252 const options = checkValidOptions ( state )
5353 const componentName = path . node . id . name
5454
5555 functionBodyPushAttributes ( t , path , options , componentName )
5656 } ,
57- ArrowFunctionExpression ( path , state ) {
57+ ArrowFunctionExpression ( path , state ) {
5858 const options = checkValidOptions ( state )
5959 if ( ! path . parent . id || ! path . parent . id . name ) return
6060 const componentName = path . parent . id . name
6161
6262 functionBodyPushAttributes ( t , path , options , componentName )
6363 } ,
64- ClassDeclaration ( path , state ) {
65- let name = path . get ( 'id' )
66- let properties = path . get ( 'body' ) . get ( 'body' )
64+ ClassDeclaration ( path , state ) {
65+ const name = path . get ( 'id' )
66+ const properties = path . get ( 'body' ) . get ( 'body' )
6767
68- let render = properties . find ( prop => {
68+ const render = properties . find ( prop => {
6969 return (
7070 prop . isClassMethod ( ) &&
7171 prop . get ( 'key' ) . isIdentifier ( { name : 'render' } )
@@ -79,7 +79,7 @@ export default function ({types: t}) {
7979 const options = checkValidOptions ( state )
8080
8181 render . traverse ( {
82- ReturnStatement ( returnStatement ) {
82+ ReturnStatement ( returnStatement ) {
8383 const arg = returnStatement . get ( 'argument' )
8484 if ( ! arg . isJSXElement ( ) ) return
8585
0 commit comments