Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/dhruvdutt/es5-function-to-class-codemod
:package: Transform ES5 Functions to ES6 Classes
https://github.com/dhruvdutt/es5-function-to-class-codemod
codemod es5 es6 javascript jscodeshift
Last synced: about 1 month ago
JSON representation
:package: Transform ES5 Functions to ES6 Classes
- Host: GitHub
- URL: https://github.com/dhruvdutt/es5-function-to-class-codemod
- Owner: dhruvdutt
- License: mit
- Created: 2018-04-07T08:50:28.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2019-06-20T18:37:33.000Z (over 5 years ago)
- Last Synced: 2024-10-14T14:17:38.982Z (about 2 months ago)
- Topics: codemod, es5, es6, javascript, jscodeshift
- Language: JavaScript
- Homepage:
- Size: 12.7 KB
- Stars: 31
- Watchers: 3
- Forks: 5
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-codemods - es5-function-to-class-codemod - Transform ES5 Functions to ES6 Classes. (JavaScript)
- awesome-jscodeshift - es5-function-to-class-codemod - Transform ES5 Functions to ES6 Classes. (Table of Contents / Codemods)
README
# Transform ES5 Functions to ES6 Classes :package:
[![npm](https://img.shields.io/npm/v/func-to-classes.svg)](https://www.npmjs.com/package/func-to-classes)
[![Awesome](https://cdn.rawgit.com/sindresorhus/awesome/d7305f38d29fed78fa85652e3a63e154dd8e8829/media/badge.svg)](https://github.com/sejoker/awesome-jscodeshift#codemods)### [Live Demo](https://astexplorer.net/#/gist/855cc00b6ebfe60f53b2c0543482ee92/) 💻
#### Features :100:
- [x] Methods on `prototype`
- [x] Static Methods on `prototype`
- [x] Variables and Literals on `prototype`
- [x] Getters, Setters with `defineProperty`
- [x] Block-level Variables#### Sample Input 🛴 and Output :rocket:
![input2](https://user-images.githubusercontent.com/5961873/38467870-ae616014-3b5b-11e8-8b92-87bdde827546.png)[Complex example](https://astexplorer.net/#/gist/541ba10e75228eeb83ccf95589b0bd76): Multiple functions in same file with one of the functions having same name.
#### Setup and Run :runner:
```bash
npm i -g jscodeshift
git clone --depth=1 https://github.com/dhruvdutt/es5-function-to-class-codemod codemod && cd codemod
jscodeshift -t func-to-class.js example/input.js
```##### Similar project - [lebab](https://uniibu.github.io/lebab-ce/). It doesn't currently support:
- [ ] Static Methods on `prototype`
- [ ] Block-level Variables