Created
April 21, 2016 10:36
-
-
Save sibelius/bd775b266d464e9618de46df00eed73b to your computer and use it in GitHub Desktop.
Convert import React, { Component } from 'react-native' to import React, { Component } from '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
// find and update all import React, { Component } from 'react-native' | |
root | |
.find(j.ImportDeclaration, { | |
source: { | |
value: 'react-native' | |
} | |
}) | |
.filter(({node}) => { | |
// check React or { Component } from 'react-native' | |
const nodes = node.specifiers.filter(imports => { | |
return imports.type === 'ImportDefaultSpecifier' && imports.local.name === 'React' || | |
imports.type === 'ImportSpecifier' && imports.local.name === 'Component'; | |
}); | |
return nodes.length > 0; | |
}) | |
.forEach(updateImport); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment