Skip to content

Commit 57ff604

Browse files
authored
Fix Flow and lint issues in Replay RDT fork (#17)
* Fix Flow issues in Replay RDT fork * Fix outstanding lint issues
1 parent 849217d commit 57ff604

File tree

7 files changed

+40
-37
lines changed

7 files changed

+40
-37
lines changed

packages/react-devtools-extensions/src/backend.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,9 @@ function setup(hook: ?DevToolsHook) {
2424
return;
2525
}
2626

27-
const bridge = new Bridge({
27+
const bridge = new Bridge<any, any>({
2828
listen(fn) {
29-
const listener = event => {
29+
const listener = (event: any) => {
3030
if (
3131
event.source !== window ||
3232
!event.data ||
@@ -42,7 +42,7 @@ function setup(hook: ?DevToolsHook) {
4242
window.removeEventListener('message', listener);
4343
};
4444
},
45-
send(event, payload, transferable) {
45+
send(event: string, payload: any, transferable: any) {
4646
window.postMessage(
4747
{
4848
source: 'react-devtools-bridge',

packages/react-devtools-extensions/src/utils.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
/* global chrome */
1+
// /* global chrome */
22

3-
import type {BrowserTheme} from 'react-devtools-shared/src/devtools/views/DevTools';
3+
// import type {BrowserTheme} from 'react-devtools-shared/src/devtools/views/DevTools';
44

55
// REPLAY Our RDT integration is only for Chrome currently
66
export const IS_EDGE = false; // navigator.userAgent.indexOf('Edg') >= 0;

packages/react-devtools-shared/src/backend/agent.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@ export default class Agent extends EventEmitter<{
206206

207207
// Notify the frontend if the backend supports the Storage API (e.g. localStorage).
208208
// If not, features like reload-and-profile will not work correctly and must be disabled.
209-
let isBackendStorageAPISupported = false;
209+
const isBackendStorageAPISupported = false;
210210

211211
bridge.send('isBackendStorageAPISupported', isBackendStorageAPISupported);
212212
bridge.send('isSynchronousXHRSupported', isSynchronousXHRSupported());
@@ -216,11 +216,11 @@ export default class Agent extends EventEmitter<{
216216
inData,
217217
) => {
218218
let rv;
219-
this._bridge = {
219+
this._bridge = ({
220220
send(event, data) {
221221
rv = {event, data};
222222
},
223-
};
223+
}: any);
224224
try {
225225
this[inEvent](inData);
226226
} catch (err) {

packages/react-devtools-shared/src/backend/console.js

+5-1
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,11 @@ export function registerRenderer(
136136
// currentDispatcherRef gets injected for v16.8+ to support hooks inspection.
137137
// getCurrentFiber gets injected for v16.9+.
138138
if (currentDispatcherRef != null && typeof getCurrentFiber === 'function') {
139-
const {ReactTypeOfWork} = getInternalReactConstants(version);
139+
const {ReactTypeOfWork} = getInternalReactConstants(
140+
version,
141+
// REPLAY Our fork will never run this code anyway, make Flow happy
142+
() => 0,
143+
);
140144

141145
injectedRenderers.set(renderer, {
142146
currentDispatcherRef,

packages/react-devtools-shared/src/backend/renderer.js

+9-10
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ import {
6363
TREE_OPERATION_UPDATE_ERRORS_OR_WARNINGS,
6464
TREE_OPERATION_UPDATE_TREE_BASE_DURATION,
6565
} from '../constants';
66-
import {HooksNode, inspectHooksOfFiber} from 'react-debug-tools';
66+
import {inspectHooksOfFiber} from 'react-debug-tools';
6767
import {
6868
patchConsoleUsingWindowValues,
6969
registerRenderer as registerRendererWithConsole,
@@ -96,8 +96,7 @@ import is from 'shared/objectIs';
9696
import hasOwnProperty from 'shared/hasOwnProperty';
9797
// REPLAY Not doing any profiling work for the foreseeable future, disable this
9898
// import {createProfilingHooks} from './profilingHooks';
99-
100-
import type {GetTimelineData, ToggleProfilingStatus} from './profilingHooks';
99+
import type {ToggleProfilingStatus} from './profilingHooks';
101100
import type {Fiber} from 'react-reconciler/src/ReactInternalTypes';
102101
import type {
103102
ChangeDescription,
@@ -736,7 +735,6 @@ export function attach(
736735
} = ReactPriorityLevels;
737736

738737
const {
739-
getLaneLabelMap,
740738
injectProfilingHooks,
741739
overrideHookState,
742740
overrideHookStateDeletePath,
@@ -772,11 +770,12 @@ export function attach(
772770
};
773771
}
774772

775-
let getTimelineData: null | GetTimelineData = null;
776-
let toggleProfilingStatus: null | ToggleProfilingStatus = null;
777-
773+
const toggleProfilingStatus: null | ToggleProfilingStatus = null;
778774
// REPLAY Not doing any profiling work for the foreseeable future, disable this
779775
/*
776+
let getTimelineData: null | GetTimelineData = null;
777+
778+
780779
if (typeof injectProfilingHooks === 'function') {
781780
const response = createProfilingHooks({
782781
getDisplayNameForFiber,
@@ -2485,7 +2484,7 @@ export function attach(
24852484
if (
24862485
mostRecentlyInspectedElement !== null &&
24872486
mostRecentlyInspectedElement.id === id &&
2488-
fiberRenderered
2487+
fiberRendered
24892488
) {
24902489
// If this Fiber has updated, clear cached inspected data.
24912490
// If it is inspected again, it may need to be re-run to obtain updated hooks values.
@@ -3925,6 +3924,7 @@ export function attach(
39253924
prevFiber.memoizedState,
39263925
fiber.memoizedState,
39273926
);
3927+
// eslint-disable-next-line eqeqeq
39283928
return indices == null || indices.length == 0 ? [] : indices;
39293929
}
39303930
return [];
@@ -4318,7 +4318,7 @@ export function attach(
43184318
},
43194319
);
43204320

4321-
let timelineData: null = null;
4321+
const timelineData: null = null;
43224322

43234323
// REPLAY Not doing any profiling work for the foreseeable future, disable this
43244324
/*
@@ -4833,7 +4833,6 @@ export function attach(
48334833
setTrackedPath,
48344834
shouldFilterFiber,
48354835
startProfiling,
4836-
shouldFilterFiber,
48374836
stopProfiling,
48384837
storeAsGlobal,
48394838
unpatchConsoleForStrictMode,

packages/react-devtools-shared/src/devtools/store.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -60,10 +60,10 @@ const debug = (methodName: string, ...args: Array<string>) => {
6060
}
6161
};
6262

63-
const LOCAL_STORAGE_COLLAPSE_ROOTS_BY_DEFAULT_KEY =
64-
'React::DevTools::collapseNodesByDefault';
65-
const LOCAL_STORAGE_RECORD_CHANGE_DESCRIPTIONS_KEY =
66-
'React::DevTools::recordChangeDescriptions';
63+
// const LOCAL_STORAGE_COLLAPSE_ROOTS_BY_DEFAULT_KEY =
64+
// 'React::DevTools::collapseNodesByDefault';
65+
// const LOCAL_STORAGE_RECORD_CHANGE_DESCRIPTIONS_KEY =
66+
// 'React::DevTools::recordChangeDescriptions';
6767

6868
type ErrorAndWarningTuples = Array<{id: number, index: number}>;
6969

packages/react-devtools-shared/src/utils.js

+14-14
Original file line numberDiff line numberDiff line change
@@ -48,12 +48,12 @@ import {
4848
TREE_OPERATION_SET_SUBTREE_MODE,
4949
TREE_OPERATION_UPDATE_ERRORS_OR_WARNINGS,
5050
TREE_OPERATION_UPDATE_TREE_BASE_DURATION,
51-
LOCAL_STORAGE_COMPONENT_FILTER_PREFERENCES_KEY,
52-
LOCAL_STORAGE_OPEN_IN_EDITOR_URL,
53-
LOCAL_STORAGE_SHOULD_BREAK_ON_CONSOLE_ERRORS,
54-
LOCAL_STORAGE_SHOULD_APPEND_COMPONENT_STACK_KEY,
55-
LOCAL_STORAGE_SHOW_INLINE_WARNINGS_AND_ERRORS_KEY,
56-
LOCAL_STORAGE_HIDE_CONSOLE_LOGS_IN_STRICT_MODE,
51+
// LOCAL_STORAGE_COMPONENT_FILTER_PREFERENCES_KEY,
52+
// LOCAL_STORAGE_OPEN_IN_EDITOR_URL,
53+
// LOCAL_STORAGE_SHOULD_BREAK_ON_CONSOLE_ERRORS,
54+
// LOCAL_STORAGE_SHOULD_APPEND_COMPONENT_STACK_KEY,
55+
// LOCAL_STORAGE_SHOW_INLINE_WARNINGS_AND_ERRORS_KEY,
56+
// LOCAL_STORAGE_HIDE_CONSOLE_LOGS_IN_STRICT_MODE,
5757
} from './constants';
5858
import {
5959
ComponentFilterElementType,
@@ -390,14 +390,14 @@ export function filterOutLocationComponentFilters(
390390
return componentFilters.filter(f => f.type !== ComponentFilterLocation);
391391
}
392392

393-
function parseBool(s: ?string): ?boolean {
394-
if (s === 'true') {
395-
return true;
396-
}
397-
if (s === 'false') {
398-
return false;
399-
}
400-
}
393+
// function parseBool(s: ?string): ?boolean {
394+
// if (s === 'true') {
395+
// return true;
396+
// }
397+
// if (s === 'false') {
398+
// return false;
399+
// }
400+
// }
401401

402402
export function castBool(v: any): ?boolean {
403403
if (v === true || v === false) {

0 commit comments

Comments
 (0)