Questions tagged [codemod]

codemod is a tool/library to assist you with large-scale codebase refactors that can be partially automated but still require human oversight and occasional intervention.

20 questions
0
votes
0 answers

Transform javascript files at build time

I am working on a CLI that bootstraps a project depending on what dependencies you select you want. I need to conditionally inject certain parts into a tsx file at build time, but I dont want any trace of it in the bootstrapped project. What I want…
Julius
  • 31
  • 4
0
votes
2 answers

Changing all let variable declarations to const with codemods in a large javascript codebase

The convention I want to use in the codebase is: const a = 1; const b = 2; However, there are many areas in the code that are written like this: let a = 1, b = 2; I want to write a codemod, probably using JSCodeshift that can change the second…
0
votes
1 answer

Issues with Update variable references for jsCodemod

I'm very new to jscodeshift. Goal: I'm trying to build a codemod that does the following: Remove old import -> DONE Add new Import -> DONE Update all references of old import -> not sure how to do this I'm using transform imports library for this…
TechnoCorner
  • 4,879
  • 10
  • 43
  • 81
0
votes
1 answer

Babel types transform - adds space around operators. How to bypass?

I have a line of code I am trying to make with a babel transform. This, const [firstName, setFirstName] = useState("") However, when I run my transform to insert this code, the are both given extra space around them. So I get…
SeanMC
  • 1,960
  • 1
  • 22
  • 33
-1
votes
1 answer

Using jscodeshift, Is there a way to extract a node path from a collection if there is only one node path?

I'm just getting started with writing CodeMods with jscodeshift. I noticed that the find method seems to always return a Collection. If there is only one node path in the collection is there an easy way to extract that node path? For example, I can…
linuxdan
  • 4,476
  • 4
  • 30
  • 41
1
2