Skip to content

Commit 3149abc

Browse files
authored
[Flow] Upgrade to 68 (firefox-devtools#6501)
1 parent 4afefd5 commit 3149abc

9 files changed

Lines changed: 77 additions & 44 deletions

File tree

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@
130130
"eslint-plugin-prettier": "^2.3.1",
131131
"eslint-plugin-react": "^7.2.1",
132132
"expect.js": "^0.3.1",
133-
"flow-bin": "0.67.1",
133+
"flow-bin": "^0.68.0",
134134
"glob": "^7.0.3",
135135
"husky": "^0.14.2",
136136
"jest": "^23.0.0",

src/actions/tests/__snapshots__/ast.spec.js.snap

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,7 @@ Object {
124124
],
125125
"imports": Array [],
126126
"literals": Array [],
127+
"loading": false,
127128
"memberExpressions": Array [],
128129
"objectProperties": Array [],
129130
"variables": Array [

src/components/SecondaryPanes/Frames/Frame.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ export default class FrameComponent extends Component<FrameComponentProps> {
8787
frame: Frame,
8888
selectedFrame: Frame
8989
) {
90-
if (e.nativeEvent.which == 3) {
90+
if (e.which == 3) {
9191
return;
9292
}
9393
this.props.selectFrame(frame);

src/reducers/ast.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ export function hasSymbols(state: OuterState, source: Source): boolean {
171171
return false;
172172
}
173173

174-
return !symbols.hasOwnProperty("loading");
174+
return !symbols.loading;
175175
}
176176

177177
export function isSymbolsLoading(state: OuterState, source: Source): boolean {
@@ -180,7 +180,7 @@ export function isSymbolsLoading(state: OuterState, source: Source): boolean {
180180
return false;
181181
}
182182

183-
return symbols.hasOwnProperty("loading");
183+
return symbols.loading;
184184
}
185185

186186
export function isEmptyLineInSource(

src/reducers/sources.js

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -126,12 +126,12 @@ function update(
126126

127127
case "ADD_TAB":
128128
return state.merge({
129-
tabs: updateTabList({ sources: state }, action.url)
129+
tabs: updateTabList(state.tabs, action.url)
130130
});
131131

132132
case "MOVE_TAB":
133133
return state.merge({
134-
tabs: updateTabList({ sources: state }, action.url, action.tabIndex)
134+
tabs: updateTabList(state.tabs, action.url, action.tabIndex)
135135
});
136136

137137
case "CLOSE_TAB":
@@ -212,20 +212,16 @@ function updateSource(state: Record<SourcesState>, source: Source | Object) {
212212
return state.setIn(["sources", source.id], createSourceRecord(source));
213213
}
214214

215-
export function removeSourceFromTabList(tabs: any, url: string) {
215+
export function removeSourceFromTabList(tabs: TabList, url: string) {
216216
return tabs.filter(tab => tab != url);
217217
}
218218

219-
export function removeSourcesFromTabList(tabs: any, urls: Array<string>) {
219+
export function removeSourcesFromTabList(tabs: TabList, urls: Array<string>) {
220220
return urls.reduce((t, url) => removeSourceFromTabList(t, url), tabs);
221221
}
222222

223223
function restoreTabs() {
224224
const prefsTabs = prefs.tabs || [];
225-
if (prefsTabs.length == 0) {
226-
return;
227-
}
228-
229225
return prefsTabs;
230226
}
231227

@@ -234,9 +230,7 @@ function restoreTabs() {
234230
* @memberof reducers/sources
235231
* @static
236232
*/
237-
function updateTabList(state: OuterState, url: ?string, tabIndex?: number) {
238-
let tabs = state.sources.tabs;
239-
233+
function updateTabList(tabs: TabList, url: ?string, tabIndex?: number) {
240234
const urlIndex = tabs.indexOf(url);
241235
const includesUrl = !!tabs.find(tab => tab == url);
242236

src/workers/parser/getSymbols.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,8 @@ export type SymbolDeclarations = {|
7474
comments: Array<SymbolDeclaration>,
7575
literals: Array<IdentifierDeclaration>,
7676
hasJsx: boolean,
77-
hasTypes: boolean
77+
hasTypes: boolean,
78+
loading: false
7879
|};
7980

8081
let symbolDeclarations: Map<string, SymbolDeclarations> = new Map();
@@ -291,7 +292,8 @@ function extractSymbols(sourceId): SymbolDeclarations {
291292
imports: [],
292293
literals: [],
293294
hasJsx: false,
294-
hasTypes: false
295+
hasTypes: false,
296+
loading: false
295297
};
296298

297299
const ast = traverseAst(sourceId, {

src/workers/parser/tests/__snapshots__/getSymbols.spec.js.snap

Lines changed: 54 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,9 @@ literals:
9898
9999
hasJsx: false
100100
101-
hasTypes: false"
101+
hasTypes: false
102+
103+
loading: false"
102104
`;
103105

104106
exports[`Parser.getSymbols call expression 1`] = `
@@ -155,7 +157,9 @@ literals:
155157
156158
hasJsx: false
157159
158-
hasTypes: false"
160+
hasTypes: false
161+
162+
loading: false"
159163
`;
160164

161165
exports[`Parser.getSymbols call sites 1`] = `
@@ -200,7 +204,9 @@ literals:
200204
201205
hasJsx: false
202206
203-
hasTypes: false"
207+
hasTypes: false
208+
209+
loading: false"
204210
`;
205211

206212
exports[`Parser.getSymbols class 1`] = `
@@ -256,7 +262,9 @@ literals:
256262
257263
hasJsx: false
258264
259-
hasTypes: false"
265+
hasTypes: false
266+
267+
loading: false"
260268
`;
261269

262270
exports[`Parser.getSymbols component 1`] = `
@@ -431,7 +439,9 @@ literals:
431439
432440
hasJsx: true
433441
434-
hasTypes: false"
442+
hasTypes: false
443+
444+
loading: false"
435445
`;
436446

437447
exports[`Parser.getSymbols destruct 1`] = `
@@ -545,7 +555,9 @@ literals:
545555
546556
hasJsx: false
547557
548-
hasTypes: false"
558+
hasTypes: false
559+
560+
loading: false"
549561
`;
550562

551563
exports[`Parser.getSymbols es6 1`] = `
@@ -584,7 +596,9 @@ literals:
584596
585597
hasJsx: false
586598
587-
hasTypes: false"
599+
hasTypes: false
600+
601+
loading: false"
588602
`;
589603

590604
exports[`Parser.getSymbols expression 1`] = `
@@ -818,7 +832,9 @@ literals:
818832
819833
hasJsx: false
820834
821-
hasTypes: false"
835+
hasTypes: false
836+
837+
loading: false"
822838
`;
823839

824840
exports[`Parser.getSymbols finds symbols in an html file 1`] = `
@@ -904,7 +920,9 @@ literals:
904920
905921
hasJsx: false
906922
907-
hasTypes: false"
923+
hasTypes: false
924+
925+
loading: false"
908926
`;
909927

910928
exports[`Parser.getSymbols flow 1`] = `
@@ -949,7 +967,9 @@ literals:
949967
950968
hasJsx: false
951969
952-
hasTypes: true"
970+
hasTypes: true
971+
972+
loading: false"
953973
`;
954974

955975
exports[`Parser.getSymbols func 1`] = `
@@ -1043,7 +1063,9 @@ literals:
10431063
10441064
hasJsx: false
10451065
1046-
hasTypes: false"
1066+
hasTypes: false
1067+
1068+
loading: false"
10471069
`;
10481070

10491071
exports[`Parser.getSymbols function names 1`] = `
@@ -1202,7 +1224,9 @@ literals:
12021224
12031225
hasJsx: false
12041226
1205-
hasTypes: false"
1227+
hasTypes: false
1228+
1229+
loading: false"
12061230
`;
12071231

12081232
exports[`Parser.getSymbols jsx 1`] = `
@@ -1242,7 +1266,9 @@ literals:
12421266
12431267
hasJsx: true
12441268
1245-
hasTypes: false"
1269+
hasTypes: false
1270+
1271+
loading: false"
12461272
`;
12471273

12481274
exports[`Parser.getSymbols math 1`] = `
@@ -1303,7 +1329,9 @@ literals:
13031329
13041330
hasJsx: false
13051331
1306-
hasTypes: false"
1332+
hasTypes: false
1333+
1334+
loading: false"
13071335
`;
13081336

13091337
exports[`Parser.getSymbols object expressions 1`] = `
@@ -1410,7 +1438,9 @@ literals:
14101438
14111439
hasJsx: false
14121440
1413-
hasTypes: false"
1441+
hasTypes: false
1442+
1443+
loading: false"
14141444
`;
14151445

14161446
exports[`Parser.getSymbols proto 1`] = `
@@ -1478,7 +1508,9 @@ literals:
14781508
14791509
hasJsx: false
14801510
1481-
hasTypes: false"
1511+
hasTypes: false
1512+
1513+
loading: false"
14821514
`;
14831515

14841516
exports[`Parser.getSymbols react component 1`] = `
@@ -1518,7 +1550,9 @@ literals:
15181550
15191551
hasJsx: false
15201552
1521-
hasTypes: false"
1553+
hasTypes: false
1554+
1555+
loading: false"
15221556
`;
15231557

15241558
exports[`Parser.getSymbols var 1`] = `
@@ -1567,5 +1601,7 @@ literals:
15671601
15681602
hasJsx: false
15691603
1570-
hasTypes: false"
1604+
hasTypes: false
1605+
1606+
loading: false"
15711607
`;

src/workers/parser/utils/formatSymbols.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,14 +34,14 @@ function summarize(symbol) {
3434

3535
return `${loc} ${expression} ${name}${params} ${klass} ${names} ${values}`.trim(); // eslint-disable-line max-len
3636
}
37+
const bools = ["hasJsx", "hasTypes", "loading"];
38+
function formatBool(name, symbols) {
39+
return `${name}: ${symbols[name] ? "true" : "false"}`;
40+
}
3741

3842
function formatKey(name, symbols) {
39-
if (name == "hasJsx") {
40-
return `hasJsx: ${symbols.hasJsx ? "true" : "false"}`;
41-
}
42-
43-
if (name == "hasTypes") {
44-
return `hasTypes: ${symbols.hasTypes ? "true" : "false"}`;
43+
if (bools.includes(name)) {
44+
return formatBool(name, symbols);
4545
}
4646

4747
return `${name}:\n${symbols[name].map(summarize).join("\n")}`;

yarn.lock

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4698,9 +4698,9 @@ flatten@^1.0.2:
46984698
version "1.0.2"
46994699
resolved "https://registry.yarnpkg.com/flatten/-/flatten-1.0.2.tgz#dae46a9d78fbe25292258cc1e780a41d95c03782"
47004700

4701-
flow-bin@0.67.1:
4702-
version "0.67.1"
4703-
resolved "https://registry.yarnpkg.com/flow-bin/-/flow-bin-0.67.1.tgz#eabb7197cce870ac9442cfd04251c7ddc30377db"
4701+
flow-bin@^0.68.0:
4702+
version "0.68.0"
4703+
resolved "https://registry.yarnpkg.com/flow-bin/-/flow-bin-0.68.0.tgz#86c2d14857d306eb2e85e274f2eebf543564f623"
47044704

47054705
flush-write-stream@^1.0.0, flush-write-stream@^1.0.2:
47064706
version "1.0.3"

0 commit comments

Comments
 (0)