es5-function-to-class-codemod
es5-function-to-class-codemod copied to clipboard
:package: Transform ES5 Functions to ES6 Classes
Transform ES5 Functions to ES6 Classes :package:
Live Demo 💻
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:
Complex example: Multiple functions in same file with one of the functions having same name.
Setup and Run :runner:
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. It doesn't currently support:
- [ ] Static Methods on
prototype
- [ ] Block-level Variables