Removed $FlowFixMe comments
Brian Vaughn committed
May 1, 2019 at 13:59 UTC
e45deb5471ac8ec836635d9949fb6557dcec6a93
2 files changed
+58
-44
src/devtools/views/Components/ComponentFiltersModal.js
+58
-41
@@ -159,8 +159,7 @@ function ComponentFiltersModal({ store, setIsModalShowing }: Props) {
159
onChange={({ currentTarget }) =>
160
changeFilterType(
161
componentFilter,
162
- // $FlowFixMe TODO (filters)
163
- parseInt(currentTarget.value, 10)
162
+ ((parseInt(currentTarget.value, 10): any): FilterType)
163
)
164
}
165
>
@@ -182,8 +181,10 @@ function ComponentFiltersModal({ store, setIsModalShowing }: Props) {
181
onChange={({ currentTarget }) =>
182
updateFilterValueElementType(
183
componentFilter,
185
- // $FlowFixMe TODO (filters)
186
- parseInt(currentTarget.value, 10)
184
+ ((parseInt(
185
+ currentTarget.value,
186
+ 10
187
+ ): any): ElementType)
188
)
189
}
190
>
@@ -287,23 +288,25 @@ function useComponentFilters() {
288
const index = componentFilters.indexOf(componentFilter);
289
if (index >= 0) {
290
if (type === ComponentFilterElementType) {
290
- // $FlowFixMe TODO (filters)
291
- cloned[index] = ({
292
- type,
291
+ cloned[index] = {
292
+ type: ComponentFilterElementType,
293
isEnabled: componentFilter.isEnabled,
294
value: ElementTypeHostComponent,
295
- }: ElementTypeComponentFilter);
296
- } else if (
297
- type === ComponentFilterDisplayName ||
298
- type === ComponentFilterLocation
299
- ) {
300
- // $FlowFixMe TODO (filters)
301
- cloned[index] = ({
302
- type,
295
+ };
296
+ } else if (type === ComponentFilterDisplayName) {
297
+ cloned[index] = {
298
+ type: ComponentFilterDisplayName,
299
isEnabled: componentFilter.isEnabled,
300
isValid: true,
301
value: '',
306
- }: RegExpComponentFilter);
302
+ };
303
+ } else if (type === ComponentFilterLocation) {
304
+ cloned[index] = {
305
+ type: ComponentFilterLocation,
306
+ isEnabled: componentFilter.isEnabled,
307
+ isValid: true,
308
+ value: '',
309
+ };
310
}
311
}
312
return cloned;
@@ -320,13 +323,14 @@ function useComponentFilters() {
323
324
setComponentFilters(componentFilters => {
325
const cloned: Array<ComponentFilter> = [...componentFilters];
323
- const index = componentFilters.indexOf(componentFilter);
324
- if (index >= 0) {
325
- // $FlowFixMe TODO (filters)
326
- cloned[index] = {
327
- ...componentFilter,
328
- value,
329
- };
326
+ if (componentFilter.type === ComponentFilterElementType) {
327
+ const index = componentFilters.indexOf(componentFilter);
328
+ if (index >= 0) {
329
+ cloned[index] = {
330
+ ...componentFilter,
331
+ value,
332
+ };
333
+ }
334
}
335
return cloned;
336
});
@@ -342,20 +346,24 @@ function useComponentFilters() {
346
347
setComponentFilters(componentFilters => {
348
const cloned: Array<ComponentFilter> = [...componentFilters];
345
- const index = componentFilters.indexOf(componentFilter);
346
- if (index >= 0) {
347
- let isValid = true;
348
- try {
349
- new RegExp(value);
350
- } catch (error) {
351
- isValid = false;
349
+ if (
350
+ componentFilter.type === ComponentFilterDisplayName ||
351
+ componentFilter.type === ComponentFilterLocation
352
+ ) {
353
+ const index = componentFilters.indexOf(componentFilter);
354
+ if (index >= 0) {
355
+ let isValid = true;
356
+ try {
357
+ new RegExp(value);
358
+ } catch (error) {
359
+ isValid = false;
360
+ }
361
+ cloned[index] = {
362
+ ...componentFilter,
363
+ isValid,
364
+ value,
365
+ };
366
}
353
- // $FlowFixMe TODO (filters)
354
- cloned[index] = {
355
- ...componentFilter,
356
- isValid,
357
- value,
358
- };
367
}
368
return cloned;
369
});
@@ -381,11 +389,20 @@ function useComponentFilters() {
389
const cloned: Array<ComponentFilter> = [...componentFilters];
390
const index = componentFilters.indexOf(componentFilter);
391
if (index >= 0) {
384
- // $FlowFixMe TODO (filters)
385
- cloned[index] = {
386
- ...cloned[index],
387
- isEnabled,
388
- };
392
+ if (componentFilter.type === ComponentFilterElementType) {
393
+ cloned[index] = {
394
+ ...((cloned[index]: any): ElementTypeComponentFilter),
395
+ isEnabled,
396
+ };
397
+ } else if (
398
+ componentFilter.type === ComponentFilterDisplayName ||
399
+ componentFilter.type === ComponentFilterLocation
400
+ ) {
401
+ cloned[index] = {
402
+ ...((cloned[index]: any): RegExpComponentFilter),
403
+ isEnabled,
404
+ };
405
+ }
406
}
407
return cloned;
408
});
src/utils.js
-3
@@ -81,9 +81,6 @@ function toCodePoint(string: string) {
81
return string.codePointAt(0);
82
}
83
84
-// TODO (filters) Save the filters as the frontend needs them (an array, with type and "enabled" status)
85
-// Convert the fitlers to Sets for the renderer to consume.
86
-
84
export function getDefaultComponentFilters(): Array<ComponentFilter> {
85
return [
86
{