I'm playing around with jscodeshift.
My goal is to get count of all imports from a particular module in a project
import { Circle, Triangle, Rectangle } from 'geometry';
results in
{ Circle: 1, Triangle: 1, Rectangle: 1 }
I have kind of achieved what I wanted here But the only issue is that I want these stats for a whole project instead of single file.
Any idea how can I achieve this?
Not sure if I understand this correctly, are you trying to import everything from within a module without having to explicitly type their names (Circle, Triangle, etc)? Or this might help:
export const Foo = 1;
export const Bar = 2;
// geometry2.js|ts
export const Biz = 3;
// index.js|ts
import * as counts from './geometry';
import * as counts2 from './geometry2';
const data = { ...counts, ...counts2 };
console.log(data); // logs {Foo: 1, Bar: 2, Biz: 3}