UNPKG

1.68 kBMarkdownView Raw
1## Contributing
2
3### Adding a new plugin to support (when approved in the next ECMAScript version)
4
5#### Update [`pluginFeatures.js`](/data/plugin-features.js)
6
7Example:
8
9In you were going to add `**` which is in ES2016:
10
11Find the relevant entries on [compat-table](https://kangax.github.io/compat-table/):
12
13`exponentiation (**) operator`
14
15Find the corresponding babel plugin:
16
17`transform-exponentiation-operator`
18
19Add add them in this structure:
20
21```js
22// es2016
23"transform-exponentiation-operator": {
24 features: [
25 "exponentiation (**) operator",
26 ],
27},
28```
29
30#### Update [`plugins.json`](/data/plugins.json)
31
32Until `compat-table` is a standalone npm module for data we are using the git url
33
34`"compat-table": "github:kangax/compat-table#gh-pages",`
35
36So we update and then run `npm run build-data`. If there are no changes, then `plugins.json` will be the same.
37
38### Writing Tests
39
40#### General
41
42All the tests for `babel-preset-env` exist in the `test/fixtures` folder. The
43test setup and conventions are exactly the same as testing a Babel plugin, so
44please read our [documentation on writing tests](https://github.com/babel/babel/blob/master/CONTRIBUTING.md#babel-plugin-x).
45
46#### Testing the `debug` option
47
48Testing debug output to `stdout` is similar. Under the `test/debug-fixtures`,
49create a folder with a descriptive name of your test, and add the following:
50
51* Add a `options.json` file (just as the other tests, this is essentially a
52`.babelrc`) with the desired test configuration (required)
53* Add a `stdout.txt` file with the expected debug output. For added
54convenience, if there is no `stdout.txt` present, the test runner will
55generate one for you.