import type { JSCodeshift , Transform , Core } from 'jscodeshift' ; export type Context = { root : ReturnType < Core > ; j : JSCodeshift ; filename : string ; } ; export type ASTTransformation < Params = void > = { ( context , params ) : void ; } ; export default function astTransformationToJSCodeshiftModule < Params = any > ( transformAST ) { const transform = ( file , api , options ) => { const j = api . jscodeshift ; const root = j ( file . source ) ; transformAST ( { root , j , filename : file . path } , options ) ; return root . toSource ( { lineTerminator : '\n' } ) ; } ; return transform ; }