Skip to content

Commit 251b0f7

Browse files
phateddanez
authored andcommitted
Lint fixes
1 parent 657b487 commit 251b0f7

File tree

4 files changed

+87
-37
lines changed

4 files changed

+87
-37
lines changed

src/resolver/__tests__/findAllExportedComponentDefinitions-test.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,11 @@ describe('findAllExportedComponentDefinitions', () => {
1616
}
1717

1818
function findComponents(path, importer = utils.noopImporter) {
19-
return findAllExportedComponentDefinitions(path, utils.getParser(), importer);
19+
return findAllExportedComponentDefinitions(
20+
path,
21+
utils.getParser(),
22+
importer,
23+
);
2024
}
2125

2226
describe('CommonJS module exports', () => {

src/utils/__tests__/getPropType-test.js

Lines changed: 44 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -26,26 +26,34 @@ describe('getPropType', () => {
2626
];
2727

2828
simplePropTypes.forEach(type =>
29-
expect(getPropType(expression('React.PropTypes.' + type), noopImporter)).toEqual({
29+
expect(
30+
getPropType(expression('React.PropTypes.' + type), noopImporter),
31+
).toEqual({
3032
name: type,
3133
}),
3234
);
3335

3436
// It doesn't actually matter what the MemberExpression is
3537
simplePropTypes.forEach(type =>
36-
expect(getPropType(expression('Foo.' + type + '.bar'), noopImporter)).toEqual({
38+
expect(
39+
getPropType(expression('Foo.' + type + '.bar'), noopImporter),
40+
).toEqual({
3741
name: type,
3842
}),
3943
);
4044

4145
// Doesn't even have to be a MemberExpression
4246
simplePropTypes.forEach(type =>
43-
expect(getPropType(expression(type), noopImporter)).toEqual({ name: type }),
47+
expect(getPropType(expression(type), noopImporter)).toEqual({
48+
name: type,
49+
}),
4450
);
4551
});
4652

4753
it('detects complex prop types', () => {
48-
expect(getPropType(expression('oneOf(["foo", "bar"])'), noopImporter)).toEqual({
54+
expect(
55+
getPropType(expression('oneOf(["foo", "bar"])'), noopImporter),
56+
).toEqual({
4957
name: 'enum',
5058
value: [
5159
{ value: '"foo"', computed: false },
@@ -54,15 +62,19 @@ describe('getPropType', () => {
5462
});
5563

5664
// line comments are ignored
57-
expect(getPropType(expression('oneOf(["foo", // baz\n"bar"])'), noopImporter)).toEqual({
65+
expect(
66+
getPropType(expression('oneOf(["foo", // baz\n"bar"])'), noopImporter),
67+
).toEqual({
5868
name: 'enum',
5969
value: [
6070
{ value: '"foo"', computed: false },
6171
{ value: '"bar"', computed: false },
6272
],
6373
});
6474

65-
expect(getPropType(expression('oneOfType([number, bool])'), noopImporter)).toEqual({
75+
expect(
76+
getPropType(expression('oneOfType([number, bool])'), noopImporter),
77+
).toEqual({
6678
name: 'union',
6779
value: [{ name: 'number' }, { name: 'bool' }],
6880
});
@@ -88,7 +100,9 @@ describe('getPropType', () => {
88100
value: { name: 'string' },
89101
});
90102

91-
expect(getPropType(expression('shape({foo: string, bar: bool})'), noopImporter)).toEqual({
103+
expect(
104+
getPropType(expression('shape({foo: string, bar: bool})'), noopImporter),
105+
).toEqual({
92106
name: 'shape',
93107
value: {
94108
foo: {
@@ -102,7 +116,9 @@ describe('getPropType', () => {
102116
},
103117
});
104118

105-
expect(getPropType(expression('exact({foo: string, bar: bool})'), noopImporter)).toEqual({
119+
expect(
120+
getPropType(expression('exact({foo: string, bar: bool})'), noopImporter),
121+
).toEqual({
106122
name: 'exact',
107123
value: {
108124
foo: {
@@ -141,14 +157,18 @@ describe('getPropType', () => {
141157
});
142158

143159
// computed
144-
expect(getPropType(expression('shape(Child.propTypes)'), noopImporter)).toEqual({
160+
expect(
161+
getPropType(expression('shape(Child.propTypes)'), noopImporter),
162+
).toEqual({
145163
name: 'shape',
146164
value: 'Child.propTypes',
147165
computed: true,
148166
});
149167

150168
// computed
151-
expect(getPropType(expression('exact(Child.propTypes)'), noopImporter)).toEqual({
169+
expect(
170+
getPropType(expression('exact(Child.propTypes)'), noopImporter),
171+
).toEqual({
152172
name: 'exact',
153173
value: 'Child.propTypes',
154174
computed: true,
@@ -181,7 +201,9 @@ describe('getPropType', () => {
181201
var BAR = "bar";
182202
`).get('expression');
183203

184-
expect(getPropType(identifierInsideArray, noopImporter)).toMatchSnapshot();
204+
expect(
205+
getPropType(identifierInsideArray, noopImporter),
206+
).toMatchSnapshot();
185207
});
186208

187209
it('resolves memberExpressions', () => {
@@ -241,7 +263,9 @@ describe('getPropType', () => {
241263
});
242264

243265
it('detects custom validation functions for function', () => {
244-
expect(getPropType(expression('(function() {})'), noopImporter)).toMatchSnapshot();
266+
expect(
267+
getPropType(expression('(function() {})'), noopImporter),
268+
).toMatchSnapshot();
245269
});
246270

247271
it('detects custom validation functions for arrow function', () => {
@@ -257,7 +281,7 @@ describe('getPropType', () => {
257281
*/
258282
string
259283
)`),
260-
noopImporter,
284+
noopImporter,
261285
),
262286
).toMatchSnapshot();
263287
});
@@ -271,7 +295,7 @@ describe('getPropType', () => {
271295
*/
272296
string
273297
)`),
274-
noopImporter,
298+
noopImporter,
275299
),
276300
).toMatchSnapshot();
277301
});
@@ -289,7 +313,7 @@ describe('getPropType', () => {
289313
*/
290314
bar: bool
291315
})`),
292-
noopImporter,
316+
noopImporter,
293317
),
294318
).toMatchSnapshot();
295319
});
@@ -301,7 +325,7 @@ describe('getPropType', () => {
301325
foo: string.isRequired,
302326
bar: bool
303327
})`),
304-
noopImporter,
328+
noopImporter,
305329
),
306330
).toMatchSnapshot();
307331
});
@@ -319,7 +343,7 @@ describe('getPropType', () => {
319343
*/
320344
bar: bool
321345
})`),
322-
noopImporter,
346+
noopImporter,
323347
),
324348
).toMatchSnapshot();
325349
});
@@ -331,7 +355,7 @@ describe('getPropType', () => {
331355
foo: string.isRequired,
332356
bar: bool
333357
})`),
334-
noopImporter,
358+
noopImporter,
335359
),
336360
).toMatchSnapshot();
337361
});
@@ -343,7 +367,7 @@ describe('getPropType', () => {
343367
[foo]: string.isRequired,
344368
bar: bool
345369
})`),
346-
noopImporter,
370+
noopImporter,
347371
),
348372
).toMatchSnapshot();
349373
});
@@ -355,7 +379,7 @@ describe('getPropType', () => {
355379
[() => {}]: string.isRequired,
356380
bar: bool
357381
})`),
358-
noopImporter,
382+
noopImporter,
359383
),
360384
).toMatchSnapshot();
361385
});

src/utils/__tests__/resolveToValue-test.js

Lines changed: 36 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,9 @@ describe('resolveToValue', () => {
1818

1919
it('resolves simple variable declarations', () => {
2020
const path = parsePath(['var foo = 42;', 'foo;'].join('\n'));
21-
expect(resolveToValue(path, noopImporter)).toEqualASTNode(builders.literal(42));
21+
expect(resolveToValue(path, noopImporter)).toEqualASTNode(
22+
builders.literal(42),
23+
);
2224
});
2325

2426
it('resolves object destructuring', () => {
@@ -53,23 +55,29 @@ describe('resolveToValue', () => {
5355
it('resolves variable declarators to their init value', () => {
5456
const path = parse('var foo = 42;').get('body', 0, 'declarations', 0);
5557

56-
expect(resolveToValue(path, noopImporter)).toEqualASTNode(builders.literal(42));
58+
expect(resolveToValue(path, noopImporter)).toEqualASTNode(
59+
builders.literal(42),
60+
);
5761
});
5862

5963
it('resolves to class declarations', () => {
6064
const path = parsePath(`
6165
class Foo {}
6266
Foo;
6367
`);
64-
expect(resolveToValue(path, noopImporter).node.type).toBe('ClassDeclaration');
68+
expect(resolveToValue(path, noopImporter).node.type).toBe(
69+
'ClassDeclaration',
70+
);
6571
});
6672

6773
it('resolves to class function declaration', () => {
6874
const path = parsePath(`
6975
function foo() {}
7076
foo;
7177
`);
72-
expect(resolveToValue(path, noopImporter).node.type).toBe('FunctionDeclaration');
78+
expect(resolveToValue(path, noopImporter).node.type).toBe(
79+
'FunctionDeclaration',
80+
);
7381
});
7482

7583
describe('flow', () => {
@@ -78,7 +86,9 @@ describe('resolveToValue', () => {
7886
function foo() {}
7987
(foo: any);
8088
`);
81-
expect(resolveToValue(path, noopImporter).node.type).toBe('FunctionDeclaration');
89+
expect(resolveToValue(path, noopImporter).node.type).toBe(
90+
'FunctionDeclaration',
91+
);
8292
});
8393
});
8494

@@ -91,23 +101,29 @@ describe('resolveToValue', () => {
91101
function foo() {}
92102
(foo as any);
93103
`);
94-
expect(resolveToValue(path, noopImporter).node.type).toBe('FunctionDeclaration');
104+
expect(resolveToValue(path, noopImporter).node.type).toBe(
105+
'FunctionDeclaration',
106+
);
95107
});
96108

97109
it('resolves type assertions', () => {
98110
const path = parseTypescript(`
99111
function foo() {}
100112
(<any> foo);
101113
`);
102-
expect(resolveToValue(path, noopImporter).node.type).toBe('FunctionDeclaration');
114+
expect(resolveToValue(path, noopImporter).node.type).toBe(
115+
'FunctionDeclaration',
116+
);
103117
});
104118
});
105119

106120
describe('assignments', () => {
107121
it('resolves to assigned values', () => {
108122
const path = parsePath(['var foo;', 'foo = 42;', 'foo;'].join('\n'));
109123

110-
expect(resolveToValue(path, noopImporter)).toEqualASTNode(builders.literal(42));
124+
expect(resolveToValue(path, noopImporter)).toEqualASTNode(
125+
builders.literal(42),
126+
);
111127
});
112128

113129
it('resolves to other assigned value if ref is in an assignment lhs', () => {
@@ -125,9 +141,9 @@ describe('resolveToValue', () => {
125141
['var foo;', 'foo = 42;', 'foo = wrap(foo);'].join('\n'),
126142
);
127143

128-
expect(resolveToValue(path.get('right', 'arguments', 0), noopImporter)).toEqualASTNode(
129-
builders.literal(42),
130-
);
144+
expect(
145+
resolveToValue(path.get('right', 'arguments', 0), noopImporter),
146+
).toEqualASTNode(builders.literal(42));
131147
});
132148
});
133149

@@ -171,15 +187,19 @@ describe('resolveToValue', () => {
171187
it("resolves a MemberExpression to it's init value", () => {
172188
const path = parsePath(['var foo = { bar: 1 };', 'foo.bar;'].join('\n'));
173189

174-
expect(resolveToValue(path, noopImporter)).toEqualASTNode(builders.literal(1));
190+
expect(resolveToValue(path, noopImporter)).toEqualASTNode(
191+
builders.literal(1),
192+
);
175193
});
176194

177195
it('resolves a MemberExpression in the scope chain', () => {
178196
const path = parsePath(
179197
['var foo = 1;', 'var bar = { baz: foo };', 'bar.baz;'].join('\n'),
180198
);
181199

182-
expect(resolveToValue(path, noopImporter)).toEqualASTNode(builders.literal(1));
200+
expect(resolveToValue(path, noopImporter)).toEqualASTNode(
201+
builders.literal(1),
202+
);
183203
});
184204

185205
it('resolves a nested MemberExpression in the scope chain', () => {
@@ -191,7 +211,9 @@ describe('resolveToValue', () => {
191211
].join('\n'),
192212
);
193213

194-
expect(resolveToValue(path, noopImporter)).toEqualASTNode(builders.literal(1));
214+
expect(resolveToValue(path, noopImporter)).toEqualASTNode(
215+
builders.literal(1),
216+
);
195217
});
196218

197219
it('returns the last resolvable MemberExpression', () => {

src/utils/resolveToValue.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,8 @@ function findScopePath(
5252

5353
// Namespace imports are handled separately, at the site of a member expression access
5454
if (
55-
(t.ImportDefaultSpecifier.check(parentPath.node) ||
56-
t.ImportSpecifier.check(parentPath.node))
55+
t.ImportDefaultSpecifier.check(parentPath.node) ||
56+
t.ImportSpecifier.check(parentPath.node)
5757
) {
5858
let exportName;
5959
if (t.ImportDefaultSpecifier.check(parentPath.node)) {

0 commit comments

Comments
 (0)