jscodeshift icon indicating copy to clipboard operation
jscodeshift copied to clipboard

Find Identifiers that are not part of a MemberExpression

Open cpojer opened this issue 9 years ago • 2 comments

@fkling and I have both identified that this is useful.

What should the API be? We could do a filter:

j.find(j.Identifier).filter(j.identifierIsVariable)

or a find:

j.find(j.OurIdentifierType)

not sure about the naming though.

cpojer avatar Jul 31 '15 17:07 cpojer

I think it should be a filter, then we can also use it in other occasions, for example in renameTo. There are also other situations where you want to ignore identifiers:

  • Method/Function names
  • Class names

Anything else?

fkling avatar Jul 31 '15 19:07 fkling

Property names in ObjectExpressions:

{a: b} // don't rename a
{a} // rename a

cpojer avatar Jul 31 '15 20:07 cpojer