Last active
March 26, 2016 12:37
-
-
Save mofas/d4c3714462f5d7cd7ea1 to your computer and use it in GitHub Desktop.
CodeMod: Insert import react-addons-pure-render-mixin after import react
This file contains 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'; | |
import Immutable from 'immutable'; | |
import classnames from 'classnames'; |
This file contains 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 pureRenderMixinImport = j.importDeclaration( | |
[j.importDefaultSpecifier( | |
j.identifier("PureRenderMixin") | |
)], | |
j.literal("react-addons-pure-render-mixin") | |
); | |
return j(file.source) | |
.find(j.ImportDeclaration, { | |
type: "ImportDeclaration", | |
source: { | |
type: "Literal", | |
value: "react" | |
} | |
}) | |
.forEach(p => { | |
j(p).insertAfter(pureRenderMixinImport); | |
}).toSource() | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment