estraverse-fb
Advanced tools
Comparing version 1.1.1 to 1.2.0
40
keys.js
@@ -12,3 +12,39 @@ module.exports = { | ||
XJSText: null, | ||
XJSSpreadAttribute: ['argument'] | ||
}; | ||
XJSSpreadAttribute: ['argument'], | ||
/* Flow Type Annotations */ | ||
Type: [], | ||
AnyTypeAnnotation: [], | ||
VoidTypeAnnotation: [], | ||
NumberTypeAnnotation: [], | ||
StringTypeAnnotation: [], | ||
StringLiteralTypeAnnotation: ["value", "raw"], | ||
BooleanTypeAnnotation: [], | ||
TypeAnnotation: ["typeAnnotation"], | ||
NullableTypeAnnotation: ["typeAnnotation"], | ||
FunctionTypeAnnotation: ["params", "returnType", "rest", "typeParameters"], | ||
FunctionTypeParam: ["name", "typeAnnotation", "optional"], | ||
ObjectTypeAnnotation: ["properties"], | ||
ObjectTypeProperty: ["key", "value", "optional"], | ||
ObjectTypeIndexer: ["id", "key", "value"], | ||
ObjectTypeCallProperty: ["value"], | ||
QualifiedTypeIdentifier: ["qualification", "id"], | ||
GenericTypeAnnotation: ["id", "typeParameters"], | ||
MemberTypeAnnotation: ["object", "property"], | ||
UnionTypeAnnotation: ["types"], | ||
IntersectionTypeAnnotation: ["types"], | ||
TypeofTypeAnnotation: ["argument"], | ||
TypeParameterDeclaration: ["params"], | ||
TypeParameterInstantiation: ["params"], | ||
ClassProperty: ["key", "typeAnnotation"], | ||
ClassImplements: [], | ||
InterfaceDeclaration: ["id", "body", "extends"], | ||
InterfaceExtends: ["id"], | ||
TypeAlias: ["id", "typeParameters", "right"], | ||
TupleTypeAnnotation: ["types"], | ||
DeclareVariable: ["id"], | ||
DeclareFunction: ["id"], | ||
DeclareClass: ["id"], | ||
DeclareModule: ["id", "body"] | ||
/* End: Flow Type Annotations */ | ||
}; |
{ | ||
"name": "estraverse-fb", | ||
"version": "1.1.1", | ||
"version": "1.2.0", | ||
"description": "Drop-in for estraverse that enables traversal over React's JSX nodes.", | ||
@@ -5,0 +5,0 @@ "main": "estraverse-fb.js", |
@@ -5,3 +5,3 @@ estraverse-fb | ||
Drop-in for estraverse that enables traversal over React's JSX using monkey-patching technique. | ||
Drop-in for estraverse that enables traversal over React's JSX and Flow nodes using monkey-patching technique. | ||
@@ -8,0 +8,0 @@ You can use estraverse-fb in two possible ways: |
29
test.js
var assert = require('chai').assert; | ||
var parse = require('esprima-fb').parse; | ||
var originalKeys = require('./keys'); | ||
describe('works', function () { | ||
var code = '<namespace:tag textAttr="value" exprAttr={expr} {...spreadAttr}><object.prop>!</object.prop>{}</namespace:tag>'; | ||
var code = ['class MyClass{', | ||
'x: number;', | ||
'y: number;', | ||
'constructor(x: number, y: number){', | ||
'this.x = x;', | ||
'this.y = y;', | ||
'}', | ||
'render(){', | ||
'return <namespace:tag textAttr="value" exprAttr={expr} {...spreadAttr}><object.prop>!</object.prop>{}</namespace:tag>', | ||
'}', | ||
'}'].join('\n'); | ||
var ast = parse(code); | ||
var expectedKeys = [ | ||
'ClassProperty', | ||
'TypeAnnotation', | ||
'NumberTypeAnnotation', | ||
'ClassProperty', | ||
'TypeAnnotation', | ||
'NumberTypeAnnotation', | ||
'XJSElement', | ||
@@ -46,6 +64,7 @@ 'XJSOpeningElement', | ||
var actualKeys = []; | ||
var actualTypeKeys = []; | ||
traverse(ast, { | ||
enter: function (node) { | ||
if (node.type.slice(0, 3) === 'XJS') { | ||
if (originalKeys[node.type] != null) { | ||
actualKeys.push(node.type); | ||
@@ -66,3 +85,3 @@ } | ||
enter: function (node) { | ||
if (node.type.slice(0, 3) === 'XJS') { | ||
if (originalKeys[node.type] != null) { | ||
actualKeys.push(node.type); | ||
@@ -84,3 +103,3 @@ } | ||
enter: function (node) { | ||
if (node.type.slice(0, 3) === 'XJS') { | ||
if (originalKeys[node.type] != null) { | ||
actualKeys.push(node.type); | ||
@@ -100,2 +119,2 @@ } | ||
}); | ||
}); | ||
}); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
7742
157