Skip to content

Commit

Permalink
Add new flow preset
Browse files Browse the repository at this point in the history
  • Loading branch information
jamiebuilds committed Feb 9, 2017
1 parent fb0a91b commit b43e09c
Show file tree
Hide file tree
Showing 7 changed files with 88 additions and 9 deletions.
3 changes: 3 additions & 0 deletions packages/babel-preset-flow/.npmignore
@@ -0,0 +1,3 @@
src
test
node_modules
53 changes: 53 additions & 0 deletions packages/babel-preset-flow/README.md
@@ -0,0 +1,53 @@
# babel-preset-flow

> Babel preset for all Flow plugins.
This preset includes the following plugins:

- [transform-flow-strip-types](https://babeljs.io/docs/plugins/transform-flow-strip-types/)

## Example

**In**

```javascript
function foo(one: any, two: number, three?): string {}
```
**Out**
```javascript
function foo(one, two, three) {}
```
## Installation
```sh
npm install --save-dev babel-preset-flow
```
## Usage
### Via `.babelrc` (Recommended)
**.babelrc**
```json
{
"presets": ["flow"]
}
```
### Via CLI
```sh
babel --presets flow script.js
```
### Via Node API
```javascript
require("babel-core").transform("code", {
presets: ["flow"]
});
```
18 changes: 18 additions & 0 deletions packages/babel-preset-flow/package.json
@@ -0,0 +1,18 @@
{
"name": "babel-preset-flow",
"version": "6.22.2",
"description": "Babel preset for all Flow plugins.",
"author": "James Kyle <me@thejameskyle.com>",
"repository": "https://github.com/babel/babel/tree/master/packages/babel-preset-flow",
"license": "MIT",
"main": "lib/index.js",
"keywords": [
"babel-preset",
"flowtype",
"flow",
"types"
],
"dependencies": {
"babel-plugin-transform-flow-strip-types": "^6.22.0"
}
}
7 changes: 7 additions & 0 deletions packages/babel-preset-flow/src/index.js
@@ -0,0 +1,7 @@
import transformFlowStripTypes from "babel-plugin-transform-flow-strip-types";

export default {
plugins: [
transformFlowStripTypes
]
};
5 changes: 2 additions & 3 deletions packages/babel-preset-react/README.md
Expand Up @@ -2,11 +2,10 @@

> Babel preset for all React plugins.
This preset includes the following plugins:
This preset includes the following plugins/presets:

- [syntax-flow](https://babeljs.io/docs/plugins/syntax-flow/)
- [preset-flow](https://babeljs.io/docs/plugins/preset-flow/)
- [syntax-jsx](https://babeljs.io/docs/plugins/syntax-jsx/)
- [transform-flow-strip-types](https://babeljs.io/docs/plugins/transform-flow-strip-types/)
- [transform-react-jsx](https://babeljs.io/docs/plugins/transform-react-jsx/)
- [transform-react-display-name](https://babeljs.io/docs/plugins/transform-react-display-name/)

Expand Down
3 changes: 1 addition & 2 deletions packages/babel-preset-react/package.json
Expand Up @@ -8,9 +8,8 @@
"repository": "https://github.com/babel/babel/tree/master/packages/babel-preset-react",
"main": "lib/index.js",
"dependencies": {
"babel-plugin-syntax-flow": "^6.3.13",
"babel-preset-flow": "^6.22.2",
"babel-plugin-syntax-jsx": "^6.3.13",
"babel-plugin-transform-flow-strip-types": "^6.22.0",
"babel-plugin-transform-react-display-name": "^6.22.0",
"babel-plugin-transform-react-jsx": "^6.22.0",
"babel-plugin-transform-react-jsx-source": "^6.22.0",
Expand Down
8 changes: 4 additions & 4 deletions packages/babel-preset-react/src/index.js
@@ -1,6 +1,5 @@
import presetFlow from "babel-preset-flow";
import transformReactJSX from "babel-plugin-transform-react-jsx";
import transformFlowStripTypes from "babel-plugin-transform-flow-strip-types";
import transformSyntaxFlow from "babel-plugin-syntax-flow";
import transformSyntaxJSX from "babel-plugin-syntax-jsx";
import transformReactDisplayName from "babel-plugin-transform-react-display-name";

Expand All @@ -9,10 +8,11 @@ import transformReactDisplayName from "babel-plugin-transform-react-display-name
// import transformReactJSXSelf from "babel-plugin-transform-react-jsx-self";

export default {
presets: [
presetFlow
],
plugins: [
transformReactJSX,
transformFlowStripTypes,
transformSyntaxFlow,
transformSyntaxJSX,
transformReactDisplayName
],
Expand Down

0 comments on commit b43e09c

Please sign in to comment.