Galooshi / import-js

A tool to simplify importing JS modules
MIT License
526 stars 70 forks source link

Option to import with double quotes instead of single quotes #559

Closed LandonSchropp closed 7 months ago

LandonSchropp commented 3 years ago

At my company, we've standardized on using double quotes for most strings. ImportJS imports files using single strings. Is there a setting I could flip to get it to import with double quotes instead?

Thanks!

coagmano commented 3 years ago

I suspect you can use the importStatementFormatter option to do that:

importStatementFormatter({ importStatement }) {
  return importStatement.replace(/'/, '"');
},

I haven't tested this however. A simple config setting would be nicer for sure

LandonSchropp commented 3 years ago

@coagmano That did the trick with one minor change!

importStatementFormatter({ importStatement }) {
  return importStatement.replace(/'/g, '"');
},

Thanks for the help.