jscodeshift
jscodeshift copied to clipboard
Find Identifiers that are not part of a MemberExpression
@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.
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?
Property names in ObjectExpressions:
{a: b} // don't rename a
{a} // rename a