Skip to content

Instantly share code, notes, and snippets.

@burtyish
Last active December 30, 2015 11:35
Show Gist options
  • Save burtyish/11fb6ee7ef0302132af4 to your computer and use it in GitHub Desktop.
Save burtyish/11fb6ee7ef0302132af4 to your computer and use it in GitHub Desktop.
Some useful regexs for migrating cjsx files to ES6
// require -> import
([\w{},]+)[\s]?=[\s]?require[\s]?[(]?['"]([\w\/.-]+)['"][)]?
import $1 from '$2';
// module.exports -> export default
module.exports[\s]?=[\s]?([\w]+)
export default $1;
// @ -> this.
@
this.
// function declarations
:[\s]?(\(([\w,\s={}]*)\))?\s*->
($1) {
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment