Skip to content

Commit 30f3428

Browse files
danezfkling
authored andcommitted
Follow up of #139
2 parents 193499b + 5f7d9d9 commit 30f3428

File tree

2 files changed

+11
-14
lines changed

2 files changed

+11
-14
lines changed

src/__tests__/fixtures/component_2.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,3 +33,11 @@ export function chained() {
3333
export function templateLiteral() {
3434
return `foo bar`.split(' ');
3535
}
36+
37+
export default function withThis() {
38+
return this.foo();
39+
}
40+
41+
export default function withNestedMemberExpressions() {
42+
return this.blub.blob.foo();
43+
}

src/utils/isStatelessComponent.js

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -28,16 +28,6 @@ const validPossibleStatelessComponentTypes = [
2828
'ArrowFunctionExpression',
2929
];
3030

31-
function isValidCalleeType(type) {
32-
return [
33-
'Identifier',
34-
'CallExpression',
35-
'ArrayExpression',
36-
'TemplateLiteral',
37-
'Literal'
38-
].indexOf(type) < 0;
39-
}
40-
4131
function isJSXElementOrReactCreateElement(path) {
4232
return (
4333
path.node.type === 'JSXElement' ||
@@ -102,12 +92,11 @@ function returnsJSXElementOrReactCreateElementCall(path) {
10292
if (calleeValue.node.type === 'MemberExpression') {
10393
if (calleeValue.get('object').node.type === 'Identifier') {
10494
resolvedValue = resolveToValue(calleeValue.get('object'));
105-
}
106-
else {
107-
while (isValidCalleeType(calleeValue.get('object').node.type)) {
95+
} else if (types.MemberExpression.check(calleeValue.node)) {
96+
do {
10897
calleeValue = calleeValue.get('object');
10998
namesToResolve.unshift(calleeValue.get('property'));
110-
}
99+
} while (types.MemberExpression.check(calleeValue.node));
111100

112101
resolvedValue = resolveToValue(calleeValue.get('object'));
113102
}

0 commit comments

Comments
 (0)