Lebab transpiles your ES5 code to ES6/ES7.
It does exactly the opposite of what Babel does.
If you want to understand what Lebab exactly does, try the live demo.
Install
Install it using npm:
$ npm install -g lebab
Usage
Convert your old-fashioned code using the lebab cli tool,
enabling a specific transformation:
$ lebab es5.js -o es6.js --transform let
Or transform an entire directory of files in-place:
# .js files only$ lebab --replace src/js/ --transform arrow# For other file extensions, use explicit globbing$ lebab --replace 'src/js/**/*.jsx' --transform arrow
For all the possible values for --transform option
see the detailed docs below or use --help from command line.
Features and known limitations
The recommended way of using Lebab is to apply one transform at a time,
read what exactly the transform does and what are its limitations,
apply it for your code and inspect the diff carefully.
Safe transforms
These transforms can be applied with relatively high confidence.
They use pretty straight-forward and strict rules for changing the code.
The resulting code should be almost 100% equivalent of the original code.
arrow - callbacks to arrow functions
Converts bound functions like function(){}.bind(this)
not applied to unbound functions that use this
not applied to functions that use arguments
not applied to object properties (use obj-method transform)
These transforms should be applied with caution.
They either use heuristics which can't guarantee that the resulting code is equivalent of the original code,
or they have significant bugs which can result in breaking your code.
let - var to let/const
never modified variables are converted to const
properly recognizes block-scoping
splits single var declaration to multiple let/const declarations if needed
recognizes vars defined/assigned using destructuring
vars that conflict with block-scoping are not converted
repeated declarations of the same var are not converted