babel-plugin-flow-comments
Advanced tools
Comparing version 1.0.1 to 1.0.3
@@ -13,9 +13,11 @@ "use strict"; | ||
visitor: { | ||
FlowDeclaration: function FlowDeclaration() { | ||
this.addComment("leading", ":: " + this.getSource()); | ||
this.dangerouslyRemove(); | ||
Identifier: function Identifier(node, parent, scope, file) { | ||
if (!node.optional || node.typeAnnotation) { | ||
return; | ||
} | ||
this.addComment("trailing", ":: ?"); | ||
}, | ||
Flow: function Flow() { | ||
var comment = this.getSource(); | ||
Flow: function Flow(node, parent, scope, file) { | ||
var comment = this.getSource().replace("*/", "//"); | ||
if (parent.optional) comment = "?" + comment; | ||
if (comment[0] !== ":") comment = ":: " + comment; | ||
@@ -22,0 +24,0 @@ this.addComment("trailing", comment); |
{ | ||
"name": "babel-plugin-flow-comments", | ||
"version": "1.0.1", | ||
"version": "1.0.3", | ||
"description": "Turn flow type annotations into comments", | ||
@@ -9,3 +9,4 @@ "repository": "babel-plugins/babel-plugin-flow-comments", | ||
"devDependencies": { | ||
"babel": "^5.6.0" | ||
"babel": "^5.6.0", | ||
"mocha": "^2.2.5" | ||
}, | ||
@@ -15,3 +16,4 @@ "scripts": { | ||
"push": "babel-plugin publish", | ||
"test": "babel-plugin test" | ||
"test": "babel-plugin test", | ||
"test-mocha": "mocha --compilers js:babel/register" | ||
}, | ||
@@ -18,0 +20,0 @@ "keywords": [ |
# babel-plugin-flow-comments | ||
Turn flow type annotations into comments | ||
Turn flow type annotations into comments. | ||
http://flowtype.org/blog/2015/02/20/Flow-Comments.html | ||
## Example | ||
**In** | ||
```javascript | ||
function foo(bar?) {} | ||
function foo2(bar?: string) {} | ||
function foo(x: number): string {} | ||
type B = { | ||
name: string; | ||
}; | ||
``` | ||
**Out** | ||
```javascript | ||
"use strict"; | ||
function foo(bar /*:: ?*/) {} | ||
function foo2(bar /*:: ?: string*/) {} | ||
function foo(x /*: number*/) /*: string*/ {} | ||
/*:: type B = { | ||
name: string; | ||
};*/ | ||
``` | ||
## Installation | ||
@@ -6,0 +34,0 @@ |
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
3626
14
76
64
2
2