loading...

Codemod with jscodeshift help needed

email2vimalraj profile image Vimalraj Selvam ・1 min read

I'm trying to write a small codemod to refactor some of the code. Consider I've somethihng like this:

import { mod1, mod2, mod3 } from 'package1'
import localMod from 'package2'

and I wanted to change this to:

import { mod1, mod3 } from 'package1'
import * as mod2 from 'new-package'
import localMod from 'package2'

As a first step, I'm trying to remove mod2 from the 1st line of import which I did successfully, but I'm not able to remove the comma after mod1.

My code snippet so far look like this:

Please help.

Discussion

markdown guide
 

Vimal, you are removing just the Identifiers from the Specifiers, you need to remove the actual import specifiers