Skip to content

Commit e050d27

Browse files
committed
chore: Run prettier
1 parent 3773e02 commit e050d27

File tree

8 files changed

+76
-36
lines changed

8 files changed

+76
-36
lines changed

src/infer/augments.js

+4-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,10 @@ function inferAugments(comment) {
3131
name: generate(path.node.superClass).code
3232
});
3333
}
34-
} else if ((path.isInterfaceDeclaration() || path.isTSInterfaceDeclaration()) && path.node.extends) {
34+
} else if (
35+
(path.isInterfaceDeclaration() || path.isTSInterfaceDeclaration()) &&
36+
path.node.extends
37+
) {
3538
/*
3639
* extends is an array of interface identifiers or
3740
* qualified type identifiers, so we generate code

src/infer/implements.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ function inferImplements(comment) {
2828
comment.implements.push({
2929
title: 'implements',
3030
name: generate(impl).code
31-
});
31+
});
3232
});
3333
}
3434

src/infer/kind.js

+13-6
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,10 @@ function inferKind(comment) {
2222
comment.abstract = true;
2323
}
2424
} else if (
25-
t.isFunction(node) ||
26-
t.isTSDeclareMethod(node) ||
27-
t.isTSDeclareFunction(node) ||
28-
t.isFunctionTypeAnnotation(node) ||
25+
t.isFunction(node) ||
26+
t.isTSDeclareMethod(node) ||
27+
t.isTSDeclareFunction(node) ||
28+
t.isFunctionTypeAnnotation(node) ||
2929
t.isTSMethodSignature(node)
3030
) {
3131
if (node.kind === 'get' || node.kind === 'set') {
@@ -46,7 +46,10 @@ function inferKind(comment) {
4646
}
4747
} else if (t.isTypeAlias(node) || t.isTSTypeAliasDeclaration(node)) {
4848
comment.kind = 'typedef';
49-
} else if (t.isInterfaceDeclaration(node) || t.isTSInterfaceDeclaration(node)) {
49+
} else if (
50+
t.isInterfaceDeclaration(node) ||
51+
t.isTSInterfaceDeclaration(node)
52+
) {
5053
comment.kind = 'interface';
5154
} else if (t.isVariableDeclaration(node)) {
5255
if (node.kind === 'const') {
@@ -65,7 +68,11 @@ function inferKind(comment) {
6568
} else if (t.isExpressionStatement(node)) {
6669
// module.exports = function() {}
6770
findKind(node.expression.right);
68-
} else if (t.isClassProperty(node) || t.isTSPropertySignature(node) || t.isTSEnumMember(node)) {
71+
} else if (
72+
t.isClassProperty(node) ||
73+
t.isTSPropertySignature(node) ||
74+
t.isTSEnumMember(node)
75+
) {
6976
comment.kind = 'member';
7077
} else if (t.isProperty(node)) {
7178
// { foo: function() {} }

src/infer/membership.js

+25-13
Original file line numberDiff line numberDiff line change
@@ -341,7 +341,9 @@ module.exports = function() {
341341
// class Foo { prop: T }
342342
// var Foo = class { prop: T }
343343
if (
344-
(path.isClassMethod() || path.isClassProperty() || path.isTSDeclareMethod()) &&
344+
(path.isClassMethod() ||
345+
path.isClassProperty() ||
346+
path.isTSDeclareMethod()) &&
345347
path.parentPath.isClassBody() &&
346348
path.parentPath.parentPath.isClass()
347349
) {
@@ -402,7 +404,11 @@ module.exports = function() {
402404
const objectKeys = [];
403405

404406
while (!objectParent.isStatement()) {
405-
if (objectParent.isObjectProperty() || objectParent.isObjectTypeProperty() || objectParent.isTSPropertySignature()) {
407+
if (
408+
objectParent.isObjectProperty() ||
409+
objectParent.isObjectTypeProperty() ||
410+
objectParent.isTSPropertySignature()
411+
) {
406412
objectKeys.unshift(objectParent.node.key.name);
407413
}
408414

@@ -413,15 +419,18 @@ module.exports = function() {
413419
findLendsIdentifiers(objectParent.get('properties')[0]);
414420

415421
if (lendsIdentifiers) {
416-
return inferMembershipFromIdentifiers(comment, [...lendsIdentifiers, ...objectKeys]);
422+
return inferMembershipFromIdentifiers(comment, [
423+
...lendsIdentifiers,
424+
...objectKeys
425+
]);
417426
} else if (objectParent.parentPath.isAssignmentExpression()) {
418427
// Foo = { ... };
419428
// Foo.prototype = { ... };
420429
// Foo.bar = { ... };
421-
return inferMembershipFromIdentifiers(
422-
comment,
423-
[...extractIdentifiers(objectParent.parentPath.get('left')), ...objectKeys]
424-
);
430+
return inferMembershipFromIdentifiers(comment, [
431+
...extractIdentifiers(objectParent.parentPath.get('left')),
432+
...objectKeys
433+
]);
425434
} else if (objectParent.parentPath.isVariableDeclarator()) {
426435
// var Foo = { ... };
427436
return inferMembershipFromIdentifiers(comment, [
@@ -434,20 +443,23 @@ module.exports = function() {
434443
inferModuleName(currentModule || comment),
435444
...objectKeys
436445
]);
437-
} else if (objectParent.parentPath.isTypeAlias() || objectParent.parentPath.isTSTypeAliasDeclaration()) {
446+
} else if (
447+
objectParent.parentPath.isTypeAlias() ||
448+
objectParent.parentPath.isTSTypeAliasDeclaration()
449+
) {
438450
// type X = { ... }
439451
return inferMembershipFromIdentifiers(comment, [
440452
objectParent.parentPath.node.id.name,
441453
...objectKeys
442454
]);
443-
} else if (objectParent.parentPath.isInterfaceDeclaration() || objectParent.parentPath.isTSInterfaceDeclaration()) {
455+
} else if (
456+
objectParent.parentPath.isInterfaceDeclaration() ||
457+
objectParent.parentPath.isTSInterfaceDeclaration()
458+
) {
444459
// interface Foo { ... }
445460
return inferMembershipFromIdentifiers(
446461
comment,
447-
[
448-
...inferClassMembership(objectParent.parentPath),
449-
...objectKeys
450-
],
462+
[...inferClassMembership(objectParent.parentPath), ...objectKeys],
451463
'instance'
452464
);
453465
}

src/infer/params.js

+14-7
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,8 @@ function inferParams(comment) {
3838
}
3939

4040
if (
41-
!t.isFunction(path) &&
42-
!t.isTSDeclareFunction(path) &&
41+
!t.isFunction(path) &&
42+
!t.isTSDeclareFunction(path) &&
4343
!t.isTSDeclareMethod(path) &&
4444
!t.isFunctionTypeAnnotation(path) &&
4545
!t.isTSMethodSignature(path)
@@ -51,7 +51,9 @@ function inferParams(comment) {
5151
return comment;
5252
}
5353

54-
let params = t.isTSMethodSignature(path) ? path.node.parameters : path.node.params;
54+
let params = t.isTSMethodSignature(path)
55+
? path.node.parameters
56+
: path.node.params;
5557

5658
// Flow function annotations separate rest parameters into a different list
5759
if (t.isFunctionTypeAnnotation(path) && path.node.rest) {
@@ -163,7 +165,8 @@ function paramToDoc(param, prefix, i) {
163165
title: 'param',
164166
name: autoName,
165167
anonymous: true,
166-
type: (param.typeAnnotation && typeAnnotation(param.typeAnnotation)) || {
168+
type: (param.typeAnnotation &&
169+
typeAnnotation(param.typeAnnotation)) || {
167170
type: 'NameExpression',
168171
name: 'Object'
169172
},
@@ -179,7 +182,8 @@ function paramToDoc(param, prefix, i) {
179182
title: 'param',
180183
name: prefixedName,
181184
anonymous: true,
182-
type: (param.typeAnnotation && typeAnnotation(param.typeAnnotation)) || {
185+
type: (param.typeAnnotation &&
186+
typeAnnotation(param.typeAnnotation)) || {
183187
type: 'NameExpression',
184188
name: 'Object'
185189
},
@@ -203,7 +207,8 @@ function paramToDoc(param, prefix, i) {
203207
title: 'param',
204208
name: autoName,
205209
anonymous: true,
206-
type: (param.typeAnnotation && typeAnnotation(param.typeAnnotation)) || {
210+
type: (param.typeAnnotation &&
211+
typeAnnotation(param.typeAnnotation)) || {
207212
type: 'NameExpression',
208213
name: 'Array'
209214
},
@@ -259,7 +264,9 @@ function paramToDoc(param, prefix, i) {
259264
title: 'param',
260265
name: prefix ? prefix + '.' + param.name.name : param.name.name,
261266
lineNumber: param.loc.start.line,
262-
type: param.typeAnnotation ? typeAnnotation(param.typeAnnotation) : undefined
267+
type: param.typeAnnotation
268+
? typeAnnotation(param.typeAnnotation)
269+
: undefined
263270
};
264271
default: {
265272
// (a)

src/infer/properties.js

+10-4
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,14 @@ function prefixedName(name, prefix) {
1010

1111
function propertyToDoc(property, prefix) {
1212
let type;
13-
if (property.type === 'ObjectTypeProperty') { // flow
13+
if (property.type === 'ObjectTypeProperty') {
14+
// flow
1415
type = typeAnnotation(property.value);
15-
} else if (property.type === 'TSPropertySignature') { // typescript
16+
} else if (property.type === 'TSPropertySignature') {
17+
// typescript
1618
type = typeAnnotation(property.typeAnnotation);
17-
} else if (property.type === 'TSMethodSignature') { // typescript
19+
} else if (property.type === 'TSMethodSignature') {
20+
// typescript
1821
type = typeAnnotation(property);
1922
}
2023
const name = property.key.name || property.key.value;
@@ -45,7 +48,10 @@ function inferProperties(comment) {
4548
comment.properties.forEach(prop => explicitProperties.add(prop.name));
4649

4750
function inferProperties(value, prefix) {
48-
if (value.type === 'ObjectTypeAnnotation' || value.type === 'TSTypeLiteral') {
51+
if (
52+
value.type === 'ObjectTypeAnnotation' ||
53+
value.type === 'TSTypeLiteral'
54+
) {
4955
const properties = value.properties || value.members || value.body || [];
5056
properties.forEach(function(property) {
5157
if (!explicitProperties.has(prefixedName(property.key.name, prefix))) {

src/infer/return.js

+6-1
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,12 @@ function inferReturn(comment) {
9999
}
100100

101101
function getReturnType(fn) {
102-
if (t.isFunction(fn) || t.isTSDeclareFunction(fn) || t.isTSDeclareMethod(fn) || t.isFunctionTypeAnnotation(fn)) {
102+
if (
103+
t.isFunction(fn) ||
104+
t.isTSDeclareFunction(fn) ||
105+
t.isTSDeclareMethod(fn) ||
106+
t.isFunctionTypeAnnotation(fn)
107+
) {
103108
return fn.returnType;
104109
}
105110

src/type_annotation.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@ function typeAnnotation(type) {
77
if (t.isTypeAnnotation(type)) {
88
type = type.typeAnnotation;
99
}
10-
11-
return flowDoctrine(type);
10+
11+
return flowDoctrine(type);
1212
}
13-
13+
1414
if (t.isTSTypeAnnotation(type)) {
1515
type = type.typeAnnotation;
1616
}

0 commit comments

Comments
 (0)