Giter Club home page Giter Club logo

coffee-to-es2015-codemod's Introduction

coffee-to-es2015-codemod

Build Status

This repository contains a collection of codemod scripts that should help you convert your CoffeeScript codebase to ES2015.

This project requires JSCodeshift to perform the transforms.

Setup & run

  • npm install -g jscodeshift
  • git clone https://github.com/Hacker0x01/coffee-to-es2015-codemod
  • jscodeshift -t <codemod-script> <file>
  • Use the -d option for a dry-run and use -p to print the output for comparison

Motivation

Because of the nature of the transforms (reverse engineering CoffeeScript patterns from the ES5 output), I don't think that it would ever be wise to run all transforms at once without reviewing. There's simply too much assumptions in the transforms that can go wrong for other codebases. Because of this I decided to split off this repository from the espresso repository, and try very carefully to document all the specific assumptions. In the hope that these transforms can help other people as well.

Proposed steps to convert your CoffeeScript codebase

At HackerOne we decided to convert our codebase through the following steps:

  1. Convert all CoffeeScript to ES5 by running the CoffeeScript compiler
  2. Replace the CoffeeScript with the ES5 output
  3. Run the first transform (TODO: define preferred order of transforms)
  4. Create a PR/diff for the code change
  5. After the change has been accepted go back to step 3 and start the next transformation

I know that it probably goes against the nature of a lot of people to review these changes (as they tend to get very big), but it's the only way I trust to make sure nothing gets lost. Once we completed the process @Hacker0x01 I will make sure to document how everything went, and what we've learned, but until then I suggest that everybody takes precaution in using these transforms.

Thanks

A big thanks to @HipsterBrown for setting up espresso and writing the first set of transforms.

Another big thanks to @fkling for setting up JSCodeshift and to @cpojer for his awesome JSConf.EU talk.

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.