Press n or j to go to the next uncovered block, b, p or k for the previous block.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 | 2x 2x 5x 5x 8x 8x 8x 4x | /* eslint-disable functional/no-loop-statement */ /* eslint-disable functional/immutable-data */ /* eslint-disable functional/no-expression-statement */ /* eslint-disable functional/no-conditional-statement */ import { addNamed } from "@babel/helper-module-imports"; import { createMacro } from "babel-plugin-macros"; export default createMacro(({ references, babel, state }) => { const program = state.file.path; for (const refName of Object.keys(references)) { const identifierNode = addNamed(program, refName, "redux-saga/effects", { nameHint: refName, }); for (const refPath of references[refName]) { refPath.node.name = identifierNode.name; const parentPath = refPath.parentPath.parentPath; if ( parentPath.isYieldExpression() && parentPath.node.delegate === true ) { parentPath.replaceWith( babel.types.yieldExpression(parentPath.get("argument").node), ); } } } }); |