Bring your JavaScript into the future.
Installation
$ yarn global add esnext
# or, with `npm`:
$ npm install -g esnext
Usage
After installing, run esnext -h
for comprehensive usage instructions.
Features
Functions
Translate some regular functions to arrow functions:
list; // ↑ becomes ↓ list;
Declarations
Convert var
declarations to let
or const
as appropriate:
var arr = ;for var i = 0; i < 5; i++ arr; // ↑ becomes ↓ const arr = ;for let i = 0; i < 5; i++ arr;
Objects
Use shorthand syntax for various object constructs:
let person = first: first last: last { return ` `; }; // ↑ becomes ↓ let person = first last { return ` `; };
Strings
Convert string concatenation to string or template literals:
let name = 'Brian' + ' ' + 'Donovan';let greeting = 'Hello, ' + name; // ↑ becomes ↓ let name = 'Brian Donovan';let greeting = `Hello, `;
Destructuring
Convert assignments and declarations to use object destructuring syntax:
let a = obja b = objb;a = obj2a b = obj2b; // ↑ becomes ↓ let a b = obj; a b = obj2;
Modules
Translate CommonJS modules into ES6 modules:
var readFile = readFile;const MagicString = ;let ok strictEqual: eq = ; exports { ;}; // ↑ becomes ↓ ;;; { ;}
Options
'declarations.block-scope': /** * Set this to `true` to only turn `var` into `let`, never `const`. */ disableConst: boolean