@@ -33,7 +33,7 @@ module.exports = function(file, api, options) {
3333 : path . join ( process . cwd ( ) , "almin-store-state-mapping.json" ) ;
3434 let mapping = { } ;
3535 try {
36- mapping = require ( outputJSONPath )
36+ mapping = require ( outputJSONPath ) ;
3737 } catch ( error ) {
3838 mapping = { } ;
3939 }
@@ -46,7 +46,7 @@ module.exports = function(file, api, options) {
4646 return file . source ;
4747 }
4848 // transform
49- const isStoreGroupArguments = ( path ) => {
49+ const isStoreGroupArguments = path => {
5050 const parent = path . parent ;
5151 if ( ! parent ) {
5252 return false ;
@@ -62,7 +62,7 @@ module.exports = function(file, api, options) {
6262 } ;
6363
6464 // get store name
65- const getStoreNameFromElement = ( element ) => {
65+ const getStoreNameFromElement = element => {
6666 if ( ! element ) {
6767 throw new Error ( element + " is invalid" ) ;
6868 }
@@ -74,7 +74,7 @@ module.exports = function(file, api, options) {
7474 throw new Error ( element + " is invalid" ) ;
7575 } ;
7676
77- const getStateNameFromStoreName = ( storeName ) => {
77+ const getStateNameFromStoreName = storeName => {
7878 let result = null ;
7979 const found = Object . keys ( mapping ) . some ( stateName => {
8080 const storeFilePath = mapping [ stateName ] ;
@@ -97,19 +97,19 @@ module.exports = function(file, api, options) {
9797 return result ;
9898 } ;
9999 return j ( file . source )
100- . find ( j . ArrayExpression )
101- . filter ( path => {
102- return isStoreGroupArguments ( path ) ;
103- } )
104- . replaceWith ( path => {
105- const elements = path . value . elements ;
106- const objects = elements . map ( element => {
107- const storeName = getStoreNameFromElement ( element ) ;
108- const stateName = getStateNameFromStoreName ( storeName ) ;
109- // { stateName: new Store() }
110- return j . property ( "init" , j . literal ( stateName ) , element ) ;
111- } ) ;
112- return j . objectExpression ( objects )
113- } )
114- . toSource ( ) ;
115- } ;
100+ . find ( j . ArrayExpression )
101+ . filter ( path => {
102+ return isStoreGroupArguments ( path ) ;
103+ } )
104+ . replaceWith ( path => {
105+ const elements = path . value . elements ;
106+ const objects = elements . map ( element => {
107+ const storeName = getStoreNameFromElement ( element ) ;
108+ const stateName = getStateNameFromStoreName ( storeName ) ;
109+ // { stateName: new Store() }
110+ return j . property ( "init" , j . literal ( stateName ) , element ) ;
111+ } ) ;
112+ return j . objectExpression ( objects ) ;
113+ } )
114+ . toSource ( ) ;
115+ } ;
0 commit comments