GithubHelp home page GithubHelp logo

ahutchings / atom-refactoring-codemods Goto Github PK

View Code? Open in Web Editor NEW

This project forked from jurassix/atom-javascript-refactor

0.0 1.0 0.0 54 KB

atom plugin that provides refactoring support for JavaScript

License: MIT License

JavaScript 98.75% CSS 1.25%

atom-refactoring-codemods's Introduction

atom-refactoring-codemods package

Build Status Dependency Status devDependency Status

JavaScript refactoring support for Atom

This package allows you to rename a file and have all internal relative imports/requires paths be updated to new location (if moved to a new dir) and all dependent files in your projects imports/requires be updated with your new file path.

This Atom package is a work in progress. The goal is to provide refactoring support to Atom, during file rename, file or directory move, and renaming of exported module.

The UI is a work in progress, all critiques are welcome - please read the Contribute section below if you are interested in making this package better.

Usage

Right click on any .js file to expose the Rename (with refactor support) option. Selecting this option will open a modalPanel that will allow the user to update the file path/name. Pressing Enter Key will apply the file rename/move and then run a codemod on the root folder.

How it all works

atom-refactoring-codemods is a UI package that executes jscodeshift codemods in memory. I've written 2 refactoring-codemods that do the heavy lifting of building the AST and updating the sources to match.

import-declaration-transform updates all dependent import/require paths when a file has been renamed/moved. This codemod takes the previousPath and newPath of the file and then all dependent import/require paths will be updated to match the new file name/location.

Example:

import foo from './bar';

becomes

import foo from './new/path/to/bar';

import-specifier-transform updates all dependent import/require variables when a file export been renamed. This codemod takes the previousExportName and newExportName for a given file and then all dependent import/require variables will be updated to match the new file export name.

Example:

import foo from './bar';

foo();

becomes

import fooPrime from './bar';

fooPrime();

Progress

  • Single File Rename with refactors
  • Directory Rename with refactors
  • Export Rename with refactors
  • Interactive Mode - show a panel with all refactors possible let user select/deselect files to update

Install

apm i atom-refactoring-codemods

Develop

> cd atom-refactoring-codemods
> npm i
> apm link

Contribute

  • Please open an issue before submitting a PR
  • All PR's should be accompanied wth tests ๐Ÿš€

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.