jurassix / atom-javascript-refactor

atom plugin that provides refactoring support for JavaScript
MIT License
32 stars 3 forks source link

Let's add this to vscode also! #138

Open tnrich opened 7 years ago

tnrich commented 7 years ago

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 commented 7 years ago

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',
);
jurassix commented 7 years ago

@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 commented 7 years ago

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

tnrich commented 7 years ago

@jurassix okay awesome I get that now. Thanks!

tnrich commented 7 years ago

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 commented 7 years ago

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

jurassix commented 7 years ago

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.