atom-javascript-refactor icon indicating copy to clipboard operation
atom-javascript-refactor copied to clipboard

Let's add this to vscode also!

Open tnrich opened this issue 7 years ago • 7 comments

Hey @jurassix ,

I know we talked a while back on some thread about adding this to sublime and you said you were more interested in adding it to vscode. I'm using vscode now and would love to have this plugin there :)

Lemme know how I can help!

tnrich avatar Sep 22 '17 16:09 tnrich

Hey @jurassix , I've started work on a vscode extension here: https://github.com/tnrich/vscode-js-path-refactor

It seems like I might already be close to having something that works, just needs a bit more debugging.

I might need to ask you some questions about certain things I was slightly unclear on. One of them that comes to mind: Why were you importing the transforms like this:

const transform = require.resolve(
  'refactoring-codemods/lib/transformers/import-relative-transform',
);

tnrich avatar Sep 25 '17 15:09 tnrich

@tnrich it's been awhile. But I'm betting that the jscodeshift/Runner requires a path to the transform

const result = Runner.run(transform, roots, options);

require.resolve() -> https://nodejs.org/api/modules.html#modules_require_resolve

Use the internal require() machinery to look up the location of a module, but rather than loading the module, just return the resolved filename.

jurassix avatar Sep 26 '17 00:09 jurassix

@tnrich it's awesome that your moving forward with the vscode version!

jurassix avatar Sep 26 '17 00:09 jurassix

@jurassix okay awesome I get that now. Thanks!

tnrich avatar Sep 26 '17 00:09 tnrich

Okay I added a first pass here:

https://marketplace.visualstudio.com/items?itemName=tnrich.js-path-refactor

I'd love any feedback!

One thing I changed is that I force the user to choose the scope of where they want to apply the transforms because in my giant repo I usually only want to have it act on sub folders, not the entire project.

Cheers!

tnrich avatar Sep 28 '17 16:09 tnrich

Posting this here to show you and partially so I can link to the url :) untitled

tnrich avatar Sep 28 '17 18:09 tnrich

Love it! Now if you can only make file drag-n-drop fire the codemod! In atom there were no good hooks besides creating a whole TreeView.

jurassix avatar Sep 29 '17 13:09 jurassix