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
| module.exports = function (file, api) { | |
| const j = api.jscodeshift; | |
| const { CallExpression, Identifier } = j; | |
| return getReactImportStatementNode() | |
| .forEach((node, index) => { | |
| node.value.specifiers.forEach((specifier, index) => { | |
| if (specifier.local.name === "useEffect") { | |
| if (!shouldKeepUseEffectImport()) { | |
| delete node.value.specifiers[index]; |
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 (fileInfo, api) => { | |
| const j = api.jscodeshift; | |
| const root = j(fileInfo.source); | |
| const importLine = `import useEffectOnce from 'utils/useEffectOnce';`; | |
| const imports = root.find(j.ImportDeclaration); | |
| const n = imports.length; | |
| j(imports.at(n - 1).get()).insertAfter(importLine); // after the imports | |
| return root.toSource(); |
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
| module.exports = function (file, api) { | |
| const j = api.jscodeshift; | |
| const { CallExpression, Identifier } = j; | |
| return ( | |
| j(file.source) | |
| .find(CallExpression, { | |
| callee: { | |
| name: "useEffect", | |
| }, |
OlderNewer