Skip to content

Commit e09932f

Browse files
committed
Final docs (and comment/console log) cleanup
1 parent 0ad244d commit e09932f

File tree

10 files changed

+59
-244
lines changed

10 files changed

+59
-244
lines changed

src/app/__tests__/Chart_deprecated_.test.tsx

Lines changed: 0 additions & 129 deletions
This file was deleted.

src/app/components/StateRoute.tsx

Lines changed: 18 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ interface StateRouteProps {
4040
const StateRoute = (props: StateRouteProps) => {
4141
const { snapshot, hierarchy, snapshots, viewIndex } = props;
4242

43-
let isRecoil = snapshot.AtomsRelationship ? true : false;
43+
const isRecoil = snapshot.AtomsRelationship ? true : false;
4444
const [noRenderData, setNoRenderData] = useState(false);
4545

4646
// component map zoom state
@@ -50,15 +50,14 @@ const StateRoute = (props: StateRouteProps) => {
5050
k: 1,
5151
});
5252

53-
//Map
53+
// Map
5454
const renderComponentMap = () => {
5555
if (hierarchy) {
5656
return <ComponentMap viewIndex={viewIndex} snapshots={snapshots} x={x} y={y} k={k} setZoomState={setZoomState} />;
5757
}
5858
return <div className="noState">{NO_STATE_MSG}</div>;
5959
};
6060

61-
6261
// the hierarchy gets set on the first click in the page
6362
// when the page is refreshed we may not have a hierarchy, so we need to check if hierarchy was initialized
6463
// if true involk render chart with hierarchy
@@ -69,9 +68,7 @@ const StateRoute = (props: StateRouteProps) => {
6968
return <div className="noState">History graph will render on first state change</div>;
7069
};
7170

72-
const renderAtomsRelationship = () => {
73-
return <AtomsRelationship atomsRel={snapshot.AtomsRelationship} />;
74-
};
71+
const renderAtomsRelationship = () => <AtomsRelationship atomsRel={snapshot.AtomsRelationship} />;
7572

7673
// the hierarchy gets set on the first click in the page
7774
// when the page is refreshed we may not have a hierarchy, so we need to check if hierarchy was initialized
@@ -83,29 +80,15 @@ const StateRoute = (props: StateRouteProps) => {
8380
return <div className="noState">{NO_STATE_MSG}</div>;
8481
};
8582

86-
let perfChart;
87-
if (true) {
88-
89-
perfChart = (
90-
<PerfView
91-
viewIndex={viewIndex}
92-
snapshots={snapshots}
93-
setNoRenderData={setNoRenderData}
94-
width={600}
95-
height={1000}
96-
/>
97-
);
98-
}
99-
100-
//This will intermitently block Recoil PerfCharts from rendering
101-
// else {
102-
// perfChart = (
103-
// <div className="no-data-message">
104-
// Application must be running in development mode in order to view
105-
// performance data
106-
// </div>
107-
// );
108-
// }
83+
const perfChart = (
84+
<PerfView
85+
viewIndex={viewIndex}
86+
snapshots={snapshots}
87+
setNoRenderData={setNoRenderData}
88+
width={600}
89+
height={1000}
90+
/>
91+
);
10992

11093
const renderPerfView = () => <ErrorHandler>{perfChart}</ErrorHandler>;
11194

@@ -131,9 +114,12 @@ const StateRoute = (props: StateRouteProps) => {
131114
Map
132115
</NavLink>
133116

134-
{isRecoil && <NavLink className="router-link" activeClassName="is-active" to="/relationship">
135-
Relationships
136-
</NavLink>}
117+
{isRecoil
118+
&& (
119+
<NavLink className="router-link" activeClassName="is-active" to="/relationship">
120+
Relationships
121+
</NavLink>
122+
)}
137123

138124
<NavLink
139125
className="router-link"

src/backend/__tests__/chromium.test.ts

Lines changed: 0 additions & 21 deletions
This file was deleted.

src/backend/helpers.ts

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,9 @@
99
// eslint-disable-next-line import/newline-after-import
1010
const acorn = require('acorn');
1111
const jsx = require('acorn-jsx');
12+
1213
const JSXParser = acorn.Parser.extend(jsx());
14+
1315
/**
1416
* @method throttle
1517
* @param f A function to throttle
@@ -19,8 +21,8 @@ const JSXParser = acorn.Parser.extend(jsx());
1921
*/
2022
export const throttle = (f: Function, t: number): Function => {
2123
// Initialize boolean flags for callback, throttledFunc
22-
let isOnCooldown: boolean = false;
23-
let isCallQueued: boolean = false;
24+
let isOnCooldown = false;
25+
let isCallQueued = false;
2426

2527
// Wrap the passed-in function, f, in a callback function that "throttles"
2628
// (puts a limit on) the number of calls that can be made to function, f
@@ -67,7 +69,7 @@ export const throttle = (f: Function, t: number): Function => {
6769
/**
6870
* @method getHooksNames
6971
* @param elementType The fiber `type`, A stringified function of the component the Fiber whose hooks we want corresponds to
70-
* @returns An array of strings
72+
* @returns An array of strings
7173
*/
7274
export const getHooksNames = (elementType: string): Array<string> => {
7375
// Initialize empty object to store the setters and getter
@@ -82,7 +84,7 @@ export const getHooksNames = (elementType: string): Array<string> => {
8284

8385
// Begin search for hook names, only if ast has a body property.
8486
while (Object.hasOwnProperty.call(ast, 'body')) {
85-
let tsCount: number = 0; // Counter for the number of TypeScript hooks seen (to distinguish in masterState)
87+
let tsCount = 0; // Counter for the number of TypeScript hooks seen (to distinguish in masterState)
8688
ast = ast.body;
8789

8890
// Statements get all the names of the hooks. For example: useCount, useWildcard, ...
@@ -91,7 +93,7 @@ export const getHooksNames = (elementType: string): Array<string> => {
9193
* Other types: "BlockStatement" / "ExpressionStatement" / "ReturnStatement"
9294
* Iterate through AST of every function declaration
9395
* Check within each function declaration if there are hook declarations */
94-
ast.forEach((functionDec) => {
96+
ast.forEach(functionDec => {
9597
let body: any;
9698
if (functionDec.expression && functionDec.expression.body) body = functionDec.expression.body.body;
9799
else body = functionDec.body ? functionDec.body.body : [];

src/backend/index.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,6 @@ import timeJumpStart from './timeJump';
1414
import {
1515
Snapshot, Mode, SnapshotNode, MsgData,
1616
} from './types/backendTypes';
17-
import { Interface } from 'readline';
18-
1917

2018
// * State snapshot object initialized here
2119
const snapShot: Snapshot = {
@@ -45,9 +43,9 @@ function getRouteURL(node: SnapshotNode): string {
4543
}
4644

4745
// * Event listener for time-travel actions
48-
window.addEventListener('message', ({ data: { action, payload } } : MsgData) => {
46+
window.addEventListener('message', ({ data: { action, payload } }: MsgData) => {
4947
switch (action) {
50-
case 'jumpToSnap':
48+
case 'jumpToSnap':
5149
timeJump(payload, true); // * This sets state with given payload
5250
// Get the pathname from payload and add new entry to browser history
5351
// MORE: https://developer.mozilla.org/en-US/docs/Web/API/History/pushState

src/backend/linkFiber.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,7 @@ function createTree(
249249
// We then store them along with the corresponding memoizedState.queue,
250250
// which includes the dispatch() function we use to change their state.
251251
const hooksStates = traverseRecoilHooks(memoizedState, memoizedProps);
252-
hooksStates.forEach((state) => {
252+
hooksStates.forEach(state => {
253253
hooksIndex = componentActionsRecord.saveNew(
254254
state.state,
255255
state.component

src/backend/masterState.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,14 @@ import 'core-js';
88
import {
99
// eslint-disable-next-line @typescript-eslint/no-unused-vars
1010
HookStateItem,
11-
HookStates
11+
HookStates,
1212
} from './types/backendTypes';
1313

1414
const componentActionsRecord: HookStates = [];
15-
let index : number = 0;
15+
let index = 0;
1616

1717
export default {
18-
saveNew: (state, component) : number => {
18+
saveNew: (state, component): number => {
1919
componentActionsRecord[index] = { state, component };
2020
index++;
2121
return index - 1;

0 commit comments

Comments
 (0)