Last active
March 25, 2016 16:48
-
-
Save mofas/200c0020224b082ab807 to your computer and use it in GitHub Desktop.
Codemod: Replace react/addons to react
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React from 'react/addons'; | |
import Immutable from 'immutable'; | |
import classnames from 'classnames'; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export default function transformer(file, api) { | |
const j = api.jscodeshift; | |
const {expression, statement, statements} = j.template; | |
var root = j(file.source); | |
return root | |
.find(j.ImportDeclaration, { | |
type: "ImportDeclaration", | |
source: { | |
type: "Literal", | |
value: "react/addons" | |
} | |
}) | |
.replaceWith(p => { | |
return ( | |
j.importDeclaration( | |
[j.importDefaultSpecifier( | |
j.identifier("React") | |
)], | |
j.literal("react") | |
) | |
); | |
}).toSource() | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment