Skip to content

Instantly share code, notes, and snippets.

@inoyakaigor
Last active April 8, 2019 13:27
Show Gist options
  • Save inoyakaigor/e57279ca5c93688bac83d51ff8e1338e to your computer and use it in GitHub Desktop.
Save inoyakaigor/e57279ca5c93688bac83d51ff8e1338e to your computer and use it in GitHub Desktop.
React createClass to Component regexp's config for my replacer service https://inoyakaigor.ru/replacer/ add it in localStorage under 'replacers' name
[
{
"active": true,
"from": "(\\n\\s+)([_a-zA-Z]+)(\\: function\\s?)",
"to": "$1$2",
"mods": "gim"
},
{
"active": true,
"from": "(\\n\\s+)([_a-zA-Z]+)\\(([a-z_\\{\\}\\=\\[\\]\\s\\,]+)?\\) {",
"to": "$1$2 = ($3) => {",
"mods": "gim"
},
{
"active": true,
"from": "(\\n\\s+)([_a-zA-Z]+) = \\(([a-z_]+)\\) => {",
"to": "$1$2 = $3 => {",
"mods": "gim"
},
{
"active": true,
"from": "(\\s+)}(,\\n)",
"to": "$1}\\n",
"mods": "gim"
},
{
"active": true,
"from": ";\\n",
"to": "\\n",
"mods": "gim"
},
{
"active": true,
"from": "^(let|const) ([a-zA-Z]+) = React\\.createClass\\({([\\s\\S]+)}\\);?",
"to": "class $2 extends Component {\\n$3\\n}",
"mods": "gim"
},
{
"active": true,
"from": "^(.*)",
"to": "import {Component} from 'react'\\n$1",
"mods": "i"
},
{
"active": true,
"from": "(\\s+)getInitialState",
"to": "\\n state = {\\n ...this.getInitialState()\\n }$1getInitialState",
"mods": "gim"
}
]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment