Import Upstream version 1.6.0

parents
/lib
fixtures
debug-fixtures
test/tmp
{
"extends": "babel",
"parserOptions": {
"ecmaVersion": 7,
"sourceType": "module"
}
}
# Configuration for probot-stale - https://github.com/probot/stale
# Number of days of inactivity before an Issue or Pull Request becomes stale
daysUntilStale: 60
# Number of days of inactivity before a stale Issue or Pull Request is closed
daysUntilClose: 7
# Issues or Pull Requests with these labels will never be considered stale. Set to `[]` to disable
exemptLabels:
- has pr
- pinned
- security
# Label to use when marking as stale
staleLabel: stale
# Comment to post when marking as stale. Set to `false` to disable
markComment: >
This issue has been automatically marked as `stale` because it has not had
recent activity 😴. It will be closed if no further activity occurs. Thank you
for your contributions 👌!
# Comment to post when removing the stale label. Set to `false` to disable
unmarkComment: false
# Comment to post when closing a stale Issue or Pull Request. Set to `false` to disable
closeComment: false
# Limit to only `issues` or `pulls`
# only: issues
node_modules
coverage
lib
test/tmp
.DS_Store
*.log
.vscode
.nyc_output
tmp
babel-preset-env-*.tgz
coverage
src
test
node_modules
scripts
.eslintignore
.travis.yml
codecov.yml
yarn.lock
.nyc_output
.vscode
.eslintrc
babel-preset-env-*.tgz
git:
depth: 3
sudo: false
language: node_js
cache:
yarn: true
directories:
- node_modules
node_js:
- "8"
- '6'
- '4'
- '0.12'
- '0.10'
env:
global:
- BABEL_ENV=test
matrix:
- PKG_CMD="npm"
- PKG_CMD="yarn"
before_install:
- nvm use $TRAVIS_NODE_VERSION
- npm set loglevel error
- npm set progress false
- 'if [ $PKG_CMD = "yarn" ]; then curl -o- -L https://yarnpkg.com/install.sh | bash && PATH=$HOME/.yarn/bin:$PATH ; fi'
install:
- $PKG_CMD install
script:
- 'if [ -n "${LINT-}" ]; then $PKG_CMD run lint ; fi'
- 'if [ -n "${SMOKE_TEST-}" ]; then node scripts/smoke-test.js ; fi'
- 'if [ -z "${LINT-}" ] && [ -z "${SMOKE_TEST-}" ]; then $PKG_CMD run test-ci ; fi'
matrix:
fast_finish: true
exclude:
- node_js: "0.10"
env: PKG_CMD="yarn"
- node_js: "0.12"
env: PKG_CMD="yarn"
include:
- node_js: "node"
env: LINT=true PKG_CMD="npm"
- node_js: "node"
env: SMOKE_TEST=true PKG_CMD="npm"
after_success: 'if [ -z "${LINT-}" ] && [ -z "${SMOKE_TEST-}" ]; then npm run coverage-ci ; fi'
This diff is collapsed.
# Contributing
## Adding a new plugin to support (when approved in the next ECMAScript version)
### Update [`plugin-features.js`](https://github.com/babel/babel-preset-env/blob/master/data/plugin-features.js)
*Example:*
If you were going to add `**` which is in ES2016:
Find the relevant entries on [compat-table](https://kangax.github.io/compat-table/es2016plus/#test-exponentiation_(**)_operator):
`exponentiation (**) operator`
Find the corresponding babel plugin:
`transform-exponentiation-operator`
And add them in this structure:
```js
// es2016
"transform-exponentiation-operator": {
features: [
"exponentiation (**) operator",
],
},
```
### Update [`built-in-features.js`](https://github.com/babel/babel-preset-env/blob/master/data/built-in-features.js)
*Example:*
In case you want to add `Object.values` which is in ES2017:
Find the relevant feature and subfeature on [compat-table](https://kangax.github.io/compat-table/es2016plus/#test-Object_static_methods_Object.values)
and split it with `/`:
`Object static methods / Object.values`
Find the corresponding module on [core-js](https://github.com/zloirock/core-js/tree/master/modules):
`es7.object.values.js`
Find required ES version in [`built-in-features.js`](https://github.com/babel/babel-preset-env/blob/master/data/built-in-features.js) and add the new feature:
```js
const es2017 = {
//...
"es7.object.values": "Object static methods / Object.values"
}
```
### Update [`plugins.json`](https://github.com/babel/babel-preset-env/blob/master/data/plugins.json)
Until `compat-table` is a standalone npm module for data we are using the git url
`"compat-table": "kangax/compat-table#[latest-commit-hash]"`,
So we update and then run `npm run build-data`. If there are no changes, then `plugins.json` will be the same.
## Tests
### Running tests locally
```bash
npm test
```
### Checking code coverage locally
```bash
npm run coverage
```
### Writing tests
#### General
All the tests for `babel-preset-env` exist in the `test/fixtures` folder. The
test setup and conventions are exactly the same as testing a Babel plugin, so
please read our [documentation on writing tests](https://github.com/babel/babel/blob/master/CONTRIBUTING.md#babel-plugin-x).
#### Testing the `debug` option
Testing debug output to `stdout` is similar. Under the `test/debug-fixtures`,
create a folder with a descriptive name of your test, and add the following:
* Add a `options.json` file (just as the other tests, this is essentially a
`.babelrc`) with the desired test configuration (required)
* Add a `stdout.txt` file with the expected debug output. For added
convenience, if there is no `stdout.txt` present, the test runner will
generate one for you.
MIT License
Copyright (c) 2016 Babel
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
This diff is collapsed.
coverage:
parsers:
javascript:
enable_partials: yes
// https://github.com/zloirock/core-js
const typedArrayMethods = [
"typed arrays / %TypedArray%.from",
"typed arrays / %TypedArray%.of",
"typed arrays / %TypedArray%.prototype.subarray",
"typed arrays / %TypedArray%.prototype.join",
"typed arrays / %TypedArray%.prototype.indexOf",
"typed arrays / %TypedArray%.prototype.lastIndexOf",
"typed arrays / %TypedArray%.prototype.slice",
"typed arrays / %TypedArray%.prototype.every",
"typed arrays / %TypedArray%.prototype.filter",
"typed arrays / %TypedArray%.prototype.forEach",
"typed arrays / %TypedArray%.prototype.map",
"typed arrays / %TypedArray%.prototype.reduce",
"typed arrays / %TypedArray%.prototype.reduceRight",
"typed arrays / %TypedArray%.prototype.reverse",
"typed arrays / %TypedArray%.prototype.some",
"typed arrays / %TypedArray%.prototype.sort",
"typed arrays / %TypedArray%.prototype.copyWithin",
"typed arrays / %TypedArray%.prototype.find",
"typed arrays / %TypedArray%.prototype.findIndex",
"typed arrays / %TypedArray%.prototype.fill",
"typed arrays / %TypedArray%.prototype.keys",
"typed arrays / %TypedArray%.prototype.values",
"typed arrays / %TypedArray%.prototype.entries",
"typed arrays / %TypedArray%.prototype[Symbol.iterator]",
"typed arrays / %TypedArray%[Symbol.species]",
];
const es2015 = {
"es6.typed.array-buffer": "typed arrays / ArrayBuffer[Symbol.species]",
"es6.typed.data-view": "typed arrays / DataView",
"es6.typed.int8-array": {
features: ["typed arrays / Int8Array"].concat(typedArrayMethods)
},
"es6.typed.uint8-array": {
features: ["typed arrays / Uint8Array"].concat(typedArrayMethods)
},
"es6.typed.uint8-clamped-array": {
features: ["typed arrays / Uint8ClampedArray"].concat(typedArrayMethods)
},
"es6.typed.int16-array": {
features: ["typed arrays / Int16Array"].concat(typedArrayMethods)
},
"es6.typed.uint16-array": {
features: ["typed arrays / Uint16Array"].concat(typedArrayMethods)
},
"es6.typed.int32-array": {
features: ["typed arrays / Int32Array"].concat(typedArrayMethods)
},
"es6.typed.uint32-array": {
features: ["typed arrays / Uint32Array"].concat(typedArrayMethods)
},
"es6.typed.float32-array": {
features: ["typed arrays / Float32Array"].concat(typedArrayMethods)
},
"es6.typed.float64-array": {
features: ["typed arrays / Float64Array"].concat(typedArrayMethods)
},
"es6.map": "Map",
"es6.set": "Set",
"es6.weak-map": "WeakMap",
"es6.weak-set": "WeakSet",
// Proxy not implementable
"es6.reflect.apply": "Reflect / Reflect.apply",
"es6.reflect.construct": "Reflect / Reflect.construct",
"es6.reflect.define-property": "Reflect / Reflect.defineProperty",
"es6.reflect.delete-property": "Reflect / Reflect.deleteProperty",
"es6.reflect.get": "Reflect / Reflect.get",
"es6.reflect.get-own-property-descriptor": "Reflect / Reflect.getOwnPropertyDescriptor",
"es6.reflect.get-prototype-of": "Reflect / Reflect.getPrototypeOf",
"es6.reflect.has": "Reflect / Reflect.has",
"es6.reflect.is-extensible": "Reflect / Reflect.isExtensible",
"es6.reflect.own-keys": "Reflect / Reflect.ownKeys",
"es6.reflect.prevent-extensions": "Reflect / Reflect.preventExtensions",
"es6.reflect.set": "Reflect / Reflect.set",
"es6.reflect.set-prototype-of": "Reflect / Reflect.setPrototypeOf",
"es6.promise": "Promise",
"es6.symbol": {
features: [
"Symbol",
"Object static methods / Object.getOwnPropertySymbols",
"well-known symbols / Symbol.hasInstance",
"well-known symbols / Symbol.isConcatSpreadable",
"well-known symbols / Symbol.iterator",
"well-known symbols / Symbol.match",
"well-known symbols / Symbol.replace",
"well-known symbols / Symbol.search",
"well-known symbols / Symbol.species",
"well-known symbols / Symbol.split",
"well-known symbols / Symbol.toPrimitive",
"well-known symbols / Symbol.toStringTag",
"well-known symbols / Symbol.unscopables",
]
},
"es6.object.assign": "Object static methods / Object.assign",
"es6.object.is": "Object static methods / Object.is",
"es6.object.set-prototype-of": "Object static methods / Object.setPrototypeOf",
"es6.function.name": "function \"name\" property",
"es6.string.raw": "String static methods / String.raw",
"es6.string.from-code-point": "String static methods / String.fromCodePoint",
"es6.string.code-point-at": "String.prototype methods / String.prototype.codePointAt",
// "String.prototype methods / String.prototype.normalize" not implemented
"es6.string.repeat": "String.prototype methods / String.prototype.repeat",
"es6.string.starts-with": "String.prototype methods / String.prototype.startsWith",
"es6.string.ends-with": "String.prototype methods / String.prototype.endsWith",
"es6.string.includes": "String.prototype methods / String.prototype.includes",
"es6.regexp.flags": "RegExp.prototype properties / RegExp.prototype.flags",
"es6.regexp.match": "RegExp.prototype properties / RegExp.prototype[Symbol.match]",
"es6.regexp.replace": "RegExp.prototype properties / RegExp.prototype[Symbol.replace]",
"es6.regexp.split": "RegExp.prototype properties / RegExp.prototype[Symbol.split]",
"es6.regexp.search": "RegExp.prototype properties / RegExp.prototype[Symbol.search]",
"es6.array.from": "Array static methods / Array.from",
"es6.array.of": "Array static methods / Array.of",
"es6.array.copy-within": "Array.prototype methods / Array.prototype.copyWithin",
"es6.array.find": "Array.prototype methods / Array.prototype.find",
"es6.array.find-index": "Array.prototype methods / Array.prototype.findIndex",
"es6.array.fill": "Array.prototype methods / Array.prototype.fill",
"es6.array.iterator": {
features: [
"Array.prototype methods / Array.prototype.keys",
// can use Symbol.iterator, not implemented in many environments
// "Array.prototype methods / Array.prototype.values",
"Array.prototype methods / Array.prototype.entries",
]
},
"es6.number.is-finite": "Number properties / Number.isFinite",
"es6.number.is-integer": "Number properties / Number.isInteger",
"es6.number.is-safe-integer": "Number properties / Number.isSafeInteger",
"es6.number.is-nan": "Number properties / Number.isNaN",
"es6.number.epsilon": "Number properties / Number.EPSILON",
"es6.number.min-safe-integer": "Number properties / Number.MIN_SAFE_INTEGER",
"es6.number.max-safe-integer": "Number properties / Number.MAX_SAFE_INTEGER",
"es6.math.acosh": "Math methods / Math.acosh",
"es6.math.asinh": "Math methods / Math.asinh",
"es6.math.atanh": "Math methods / Math.atanh",
"es6.math.cbrt": "Math methods / Math.cbrt",
"es6.math.clz32": "Math methods / Math.clz32",
"es6.math.cosh": "Math methods / Math.cosh",
"es6.math.expm1": "Math methods / Math.expm1",
"es6.math.fround": "Math methods / Math.fround",
"es6.math.hypot": "Math methods / Math.hypot",
"es6.math.imul": "Math methods / Math.imul",
"es6.math.log1p": "Math methods / Math.log1p",
"es6.math.log10": "Math methods / Math.log10",
"es6.math.log2": "Math methods / Math.log2",
"es6.math.sign": "Math methods / Math.sign",
"es6.math.sinh": "Math methods / Math.sinh",
"es6.math.tanh": "Math methods / Math.tanh",
"es6.math.trunc": "Math methods / Math.trunc",
};
const es2016 = {
"es7.array.includes": "Array.prototype.includes",
};
const es2017 = {
"es7.object.values": "Object static methods / Object.values",
"es7.object.entries": "Object static methods / Object.entries",
"es7.object.get-own-property-descriptors": "Object static methods / Object.getOwnPropertyDescriptors",
"es7.string.pad-start": "String padding / String.prototype.padStart",
"es7.string.pad-end": "String padding / String.prototype.padEnd",
};
module.exports = Object.assign({}, es2015, es2016, es2017);
This diff is collapsed.
module.exports = {
// es2015
"check-es2015-constants": {
features: [
"const",
],
},
"transform-es2015-arrow-functions": {
features: [
"arrow functions",
],
},
"transform-es2015-block-scoped-functions": {
features: [
"block-level function declaration"
],
},
"transform-es2015-block-scoping": {
features: [
"const",
"let",
],
},
"transform-es2015-classes": {
features: [
"class",
"super",
],
},
"transform-es2015-computed-properties": {
features: [
"object literal extensions / computed properties",
],
},
"transform-es2015-destructuring": {
features: [
"destructuring, assignment",
"destructuring, declarations",
"destructuring, parameters",
],
},
"transform-es2015-duplicate-keys": {
features: [
"miscellaneous / duplicate property names in strict mode",
],
},
"transform-es2015-for-of": {
features: [
"for..of loops",
],
},
"transform-es2015-function-name": {
features: [
"function \"name\" property",
]
},
"transform-es2015-literals": {
features: [
"Unicode code point escapes",
],
},
"transform-es2015-object-super": {
features: [
"super",
],
},
"transform-es2015-parameters": {
features: [
"default function parameters",
"rest parameters",
],
},
"transform-es2015-shorthand-properties": {
features: [
"object literal extensions / shorthand properties",
],
},
"transform-es2015-spread": {
features: [
"spread (...) operator",
],
},
"transform-es2015-sticky-regex": {
features: [
"RegExp \"y\" and \"u\" flags / \"y\" flag, lastIndex",
"RegExp \"y\" and \"u\" flags / \"y\" flag",
],
},
"transform-es2015-template-literals": {
features: [
"template literals",
],
},
"transform-es2015-typeof-symbol": {
features: [
"Symbol / typeof support"
],
},
"transform-es2015-unicode-regex": {
features: [
"RegExp \"y\" and \"u\" flags / \"u\" flag, case folding",
"RegExp \"y\" and \"u\" flags / \"u\" flag, Unicode code point escapes",
"RegExp \"y\" and \"u\" flags / \"u\" flag",
],
},
"transform-regenerator": {
features: [
"generators",
],
},
// es2016
"transform-exponentiation-operator": {
features: [
"exponentiation (**) operator",
],
},
// es2017
"transform-async-to-generator": {
features: [
"async functions",
],
},
"syntax-trailing-function-commas": {
features: [
"trailing commas in function syntax",
],
}
};
{
"check-es2015-constants": {
"chrome": "49",
"edge": "14",
"firefox": "51",
"safari": "10",
"node": "6",
"ios": "10",
"opera": "36",
"electron": "1"
},
"transform-es2015-arrow-functions": {
"chrome": "47",
"edge": "13",
"firefox": "45",
"safari": "10",
"node": "6",
"ios": "10",
"opera": "34",
"electron": "0.36"
},
"transform-es2015-block-scoped-functions": {
"chrome": "41",
"edge": "12",
"firefox": "46",
"safari": "10",
"node": "4",
"ie": "11",
"ios": "10",
"opera": "28",
"electron": "0.24"
},
"transform-es2015-block-scoping": {
"chrome": "49",
"edge": "14",
"firefox": "51",
"safari": "10",
"node": "6",
"ios": "10",
"opera": "36",
"electron": "1"
},
"transform-es2015-classes": {
"chrome": "46",
"edge": "13",
"firefox": "45",
"safari": "10",
"node": "5",
"ios": "10",
"opera": "33",
"electron": "0.36"
},
"transform-es2015-computed-properties": {
"chrome": "44",
"edge": "12",
"firefox": "34",
"safari": "7.1",
"node": "4",
"ios": "8",
"opera": "31",
"electron": "0.31"
},
"transform-es2015-destructuring": {
"chrome": "51",
"edge": "15",
"firefox": "53",
"safari": "10",
"node": "6.5",
"ios": "10",
"opera": "38",
"electron": "1.2"
},
"transform-es2015-duplicate-keys": {
"chrome": "42",
"edge": "12",
"firefox": "34",
"safari": "9",
"node": "4",
"ios": "9",
"opera": "29",
"electron": "0.27"
},
"transform-es2015-for-of": {
"chrome": "51",
"edge": "15",
"firefox": "53",
"safari": "10",
"node": "6.5",
"ios": "10",
"opera": "38",
"electron": "1.2"
},
"transform-es2015-function-name": {
"chrome": "51",
"firefox": "53",
"safari": "10",
"node": "6.5",
"ios": "10",
"opera": "38",
"electron": "1.2"
},
"transform-es2015-literals": {
"chrome": "44",
"edge": "12",
"firefox": "53",
"safari": "9",
"node": "4",
"ios": "9",
"opera": "31",
"electron": "0.31"
},
"transform-es2015-object-super": {
"chrome": "46",
"edge": "13",
"firefox": "45",
"safari": "10",
"node": "5",
"ios": "10",
"opera": "33",
"electron": "0.36"
},
"transform-es2015-parameters": {
"chrome": "49",
"edge": "14",
"firefox": "53",
"safari": "10",
"node": "6",
"ios": "10",
"opera": "36",
"electron": "1"
},
"transform-es2015-shorthand-properties": {
"chrome": "43",
"edge": "12",
"firefox": "33",
"safari": "9",