babel-preset-airbnb
A babel preset for transforming your JavaScript for Airbnb.
Currently contains transforms for all standard syntax that is stage 4 (ES2018) or stage 3, except for the following:
- generators:
regenerator-runtime
is too heavyweight for our use. async/await
: regenerator-runtime
is too heavyweight for our use, and async-to-promises is not yet complete enough to be safely used.- async iterators: depends on both generators and
async function
s - lifted template literal restrictions: we do not use tagged template literals, nor implement custom DSLs, otherwise we would enable this.
Install
$ npm install --save-dev babel-preset-airbnb
Usage
Via .babelrc
(Recommended)
.babelrc
{
"presets": ["airbnb"]
}
Via CLI
$ babel script.js --presets airbnb
Via Node API
require("babel-core").transform("code", {
presets: ["airbnb"]
});
Targeting Environments
This module uses babel-preset-env to target specific environments.
Please refer to babel-preset-env#targets for a list of available options.
For a list of browsers please see browserlist.
You may override our default list of targets by providing your own targets
key.
{
"presets": [["airbnb", {
"targets": {
"chrome": 50,
"explorer": 11,
"firefox": 45
}
}]]
}
The following transpiles only for Node v6.
{
"presets": [["airbnb", {
"targets": {
"node": 6
}
}]]
}
If you wish, you can also inherit our default list of browsers and extend them using additionalTargets
.
{
"presets": [["airbnb", {
"additionalTargets": {
"chrome": 42,
"explorer": 8
}
}]]
}
You may override our default debug option by providing your own debug
key.
{
"presets": [["airbnb", {
"debug": true
}]]
}