Giter Site home page Giter Site logo

codemods's Introduction

EDITED codemods

This repository contains a codemod script for converting React codebases from Radium to glamor automatically. Eventually this will become a place for all sorts of JS migrations, but there's just one for now.

Setup & Run

  • npm install -g jscodeshift
  • git clone https://github.com/EDITD/codemods.git or download a zip file from https://github.com/EDITD/codemods/archive/master.zip
  • Run npm install or yarn in the codemods directory
  • jscodeshift -t <codemod-script> <path>
  • Use the -d option for a dry-run and use -p to print the output for comparison

Included Scripts

radium-to-glamor

This does a few things in order to move a codebase from Radium to glamor completely.

  • Removes all Radium imports and calls
  • Converts style={someStyles} to {...css(someStyles)} in JSX when the components are DOM components from React. Props to any other components are left as they are. If it's not possible to statically analyse whether the expression should be spread and passed into css then we add comments leading with TODO_RADIUM_TO_GLAMOR.
  • Adds import { css } from "glamor" to all files that need it

Recast Options

Options to recast's printer can be provided through the printOptions command line argument

jscodeshift -t transform.js <path> --printOptions='{"quote":"double"}'

Support and Contributing

Please feel free to make a Pull Request with any improvements!

codemods's People

Contributors

andrinealver avatar bobbyrenwick avatar

Watchers

Bernardo Raposo avatar James Shipton avatar Geoff Watts avatar James Cloos avatar  avatar Sam Whitehall avatar  avatar Panos Katseas avatar Boris Gezkovski avatar Harry Curotta avatar John Spicer avatar Chloe H-C avatar Gabriel Delavald avatar  avatar Martha Giannoudovardi avatar Deyan Vatsov avatar Svetoslav Rankov avatar Germain Chazot avatar  avatar Isobel Ormiston avatar Petter Stene Pettersen avatar Ryan avatar  avatar  avatar Jennifer Day avatar Jason Hung avatar Joe Berry avatar Brad Jack avatar Emily La Touche avatar  avatar

codemods's Issues

remove StyleRoot

Remove StyleRoot from the JSX when it get's removed from the imports (import { StyleRoot } from "radium";)

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.