Skip to content

Commit 7a5dc4e

Browse files
glebezdanez
authored andcommitted
update fixtures, clean up lint errors, update default handlers
# Conflicts: # src/Documentation.js
1 parent 5ed3c76 commit 7a5dc4e

File tree

5 files changed

+58
-7
lines changed

5 files changed

+58
-7
lines changed

src/Documentation.js

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -70,24 +70,26 @@ class Documentation {
7070

7171
if (this._props.size > 0) {
7272
obj.props = {};
73-
for (var [name, descriptor] of this._props) {
74-
if (Object.keys(descriptor).length > 0) {
75-
obj.props[name] = descriptor;
73+
for (var [propName, propDescriptor] of this._props) {
74+
if (Object.keys(propDescriptor).length > 0) {
75+
obj.props[propName] = propDescriptor;
7676
}
7777
}
7878
}
7979

8080
if (this._context.size > 0) {
8181
obj.context = {};
82-
for (var [name, descriptor] of this._context) {
83-
obj.context[name] = descriptor;
82+
for (var [contextName, contextDescriptor] of this._context) {
83+
if (Object.keys(contextDescriptor).length > 0) {
84+
obj.context[contextName] = contextDescriptor;
85+
}
8486
}
8587
}
8688

8789
if (this._childContext.size > 0) {
8890
obj.childContext = {};
89-
for (var [name, descriptor] of this._childContext) {
90-
obj.childContext[name] = descriptor;
91+
for (var [childContextName, childContextDescriptor] of this._childContext) {
92+
obj.childContext[childContextName] = childContextDescriptor;
9193
}
9294
}
9395

src/__tests__/__snapshots__/main-test.js.snap

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,22 @@ Object {
102102

103103
exports[`main fixtures processes component "component_5.js" without errors 1`] = `
104104
Object {
105+
"childContext": Object {
106+
"color": Object {
107+
"required": false,
108+
"type": Object {
109+
"name": "string",
110+
},
111+
},
112+
},
113+
"context": Object {
114+
"config": Object {
115+
"required": false,
116+
"type": Object {
117+
"name": "object",
118+
},
119+
},
120+
},
105121
"description": "",
106122
"displayName": "Button",
107123
"methods": Array [],
@@ -137,6 +153,22 @@ Object {
137153

138154
exports[`main fixtures processes component "component_6.js" without errors 1`] = `
139155
Object {
156+
"childContext": Object {
157+
"color": Object {
158+
"required": false,
159+
"type": Object {
160+
"name": "string",
161+
},
162+
},
163+
},
164+
"context": Object {
165+
"config": Object {
166+
"required": false,
167+
"type": Object {
168+
"name": "object",
169+
},
170+
},
171+
},
140172
"description": "",
141173
"displayName": "Button",
142174
"methods": Array [],

src/__tests__/fixtures/component_5.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,12 @@ Button.propTypes = {
1515
style: React.PropTypes.object,
1616
};
1717

18+
Button.childContextTypes = {
19+
color: React.PropTypes.string,
20+
};
21+
22+
Button.contextTypes = {
23+
config: React.PropTypes.object,
24+
};
25+
1826
export default Button;

src/__tests__/fixtures/component_6.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,11 @@ Button.propTypes = {
1616
style: PropTypes.object,
1717
};
1818

19+
Button.childContextTypes = {
20+
color: PropTypes.string,
21+
};
22+
23+
Button.contextTypes = {
24+
config: PropTypes.object,
25+
};
1926
export default Button;

src/main.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ import * as utils from './utils';
1818
var defaultResolver = resolver.findExportedComponentDefinition;
1919
var defaultHandlers = [
2020
handlers.propTypeHandler,
21+
handlers.contextTypeHandler,
22+
handlers.childContextTypeHandler,
2123
handlers.propTypeCompositionHandler,
2224
handlers.propDocBlockHandler,
2325
handlers.flowTypeHandler,

0 commit comments

Comments
 (0)