Skip to content

Commit 302e9e0

Browse files
committed
eslint and typescript adjustments part1
1 parent 04d0445 commit 302e9e0

File tree

7 files changed

+48
-41
lines changed

7 files changed

+48
-41
lines changed

src/app/components/PerformanceVisx.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,11 @@ const collectNodes = (snaps, componentName) => {
5454
} else {
5555
renderResult.push(renderTime);
5656
}
57-
// compare the last pushed component Data from the array to the current one to see if there are differences
57+
// compare the last pushed component Data from the array to
58+
// the current one to see if there are differences
5859
if (x !== 0 && componentsResult.length !== 0) {
59-
// needs to be stringified because values are hard to determine if true or false if in they're seen as objects
60+
// needs to be stringified because values are hard to determine if
61+
// true or false if in they're seen as objects
6062
if (JSON.stringify(Object.values(componentsResult[newChange ? componentsResult.length - 1 : trackChanges])[0]) !== JSON.stringify(cur.componentData.props)) {
6163
newChange = true;
6264
const props = { [`snapshot${x}`]: { ...cur.componentData.props } };

src/backend/linkFiber.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
/* eslint-disable no-param-reassign */
1313

1414
// import typescript types
15-
import { element } from 'prop-types';
1615
import {
1716
// tree
1817
Snapshot,
@@ -284,6 +283,7 @@ function createTree(
284283
};
285284
}
286285
} catch (error) {
286+
console.log(error);
287287
}
288288
}
289289

@@ -458,7 +458,7 @@ function createTree(
458458

459459
while (pointer !== null) {
460460
if (pointer.stateNode !== null) {
461-
rtid = `fromLinkFiber${rtidCounter++}`;
461+
rtid = `fromLinkFiber${rtidCounter += 1}`;
462462
// rtid = rtidCounter++;
463463
recoilDomNode[currentFiber.elementType.name].push(rtid);
464464
// check if rtid is already present
@@ -496,7 +496,7 @@ function createTree(
496496
}
497497
currentFiber.child.stateNode.classList.add(rtid);
498498
}
499-
rtidCounter++;
499+
rtidCounter += 1;
500500
}
501501
// checking if tree fromSibling is true
502502
if (fromSibling) {

src/backend/masterState.ts

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,12 @@ import {
1111
HookStates, // array of hook state items
1212
} from './types/backendTypes';
1313

14-
// HookState is an array that contains a "component" for every single state change that occurs in the app
14+
// HookState is an array that contains a "component" for
15+
// every single state change that occurs in the app
1516
// Information on these components include ComponentData as well as state
1617
// For class components, there will be one "component" for each snapshot
17-
// For functional components that utilize Hooks, there will be one "component" for each setter/getter every time we have a new snapshot
18+
// For functional components that utilize Hooks, there will be one "component"
19+
// for each setter/getter every time we have a new snapshot
1820
let componentActionsRecord: HookStates = [];
1921
let index = 0;
2022

@@ -30,19 +32,20 @@ export default {
3032

3133
return index - 1;
3234
},
33-
getRecordByIndex: (inputIndex: number): HookStateItem =>
34-
componentActionsRecord[inputIndex],
35-
// this is used for class components - inputIndex will always be a fixed number (coming in timeJump.ts)
36-
getComponentByIndex: (inputIndex: number): any =>
35+
getRecordByIndex: (inputIndex: number): HookStateItem => componentActionsRecord[inputIndex],
36+
// this is used for class components -
37+
/* inputIndex will always be a fixed number (coming in timeJump.ts) */
38+
getComponentByIndex: (inputIndex: number): any => (
3739
componentActionsRecord[inputIndex]
3840
? componentActionsRecord[inputIndex].component
39-
: undefined,
41+
: undefined),
4042
// this is used for react hooks - hooks will be passed in as an array from timeJump.ts
4143
getComponentByIndexHooks: (inputIndex: Array<number> = []): any => {
4244
const multiDispatch = [];
4345
for (let i = 0; i < inputIndex.length; i++) {
44-
if (componentActionsRecord[inputIndex[i]])
46+
if (componentActionsRecord[inputIndex[i]]) {
4547
multiDispatch.push(componentActionsRecord[inputIndex[i]].component);
48+
}
4649
}
4750
return multiDispatch;
4851
},

src/backend/timeJump.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,10 +63,10 @@ export default (origin, mode) => {
6363
}
6464
});
6565

66-
//REACT HOOKS
66+
// REACT HOOKS
6767
// check if component states are set with hooks
68-
// if yes, grab all relevant components for this snapshot in numArr
69-
// call dispatch on each component passing in the corresponding currState value
68+
// if yes, grab all relevant components for this snapshot in numArr
69+
// call dispatch on each component passing in the corresponding currState value
7070
if (target.state && target.state.hooksState) {
7171
const currState = target.state.hooksState;
7272
const numArr: Array<number> = [];

src/backend/tree.ts

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@
77
/* eslint-disable no-console */
88
/* eslint-disable no-param-reassign */
99

10-
import { createGenerateClassName } from '@material-ui/styles';
11-
1210
let copyInstances = 0;
1311
const circularComponentTable = new Set<Tree>();
1412
let componentNames = {};
@@ -83,14 +81,12 @@ class Tree {
8381
}
8482

8583
// Returns a unique name ready to be used
86-
checkForDuplicates(name: string) {
84+
checkForDuplicates(name: string): string {
8785
// check for empty name
8886
if (name === '' && typeof this.rtid === 'string') {
8987
name = this.rtid.replace('fromLinkFiber', '');
9088
}
91-
if (this.state === 'root') {
92-
componentNames = {};
93-
}
89+
if (this.state === 'root') componentNames = {};
9490
// check for duplicate
9591
else if (componentNames[name] !== undefined) {
9692
const count = componentNames[name] + 1;

src/extension/background.js

Lines changed: 24 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,13 @@ function createTabObj(title) {
2222
// update tabsObj
2323
return {
2424
title,
25-
// snapshots is an array of ALL state snapshots for stateful and stateless components the Reactime tab working on a specific user application
25+
// snapshots is an array of ALL state snapshots for stateful and stateless
26+
// components the Reactime tab working on a specific user application
2627
snapshots: [],
2728
// index here is the tab index that shows total amount of state changes
2829
index: 0,
29-
//* this is our pointer so we know what the current state the user is checking (this accounts for time travel aka when user clicks jump on the UI)
30+
//* this is our pointer so we know what the current state the user is checking
31+
// (this accounts for time travel aka when user clicks jump on the UI)
3032
currLocation: null,
3133
// points to the node that will generate the next child set by newest node or jump
3234
currParent: 0,
@@ -54,16 +56,32 @@ function createTabObj(title) {
5456
class Node {
5557
constructor(obj, tabObj) {
5658
// continues the order of number of total state changes
57-
this.index = tabObj.index++;
59+
this.index = tabObj.index;
60+
tabObj.index += 1;
5861
// continues the order of number of states changed from that parent
59-
this.name = tabObj.currParent += 1;
62+
tabObj.currParent += 1;
63+
this.name = tabObj.currParent;
6064
// marks from what branch this node is originated
6165
this.branch = tabObj.currBranch;
6266
this.stateSnapshot = obj;
6367
this.children = [];
6468
}
6569
}
6670

71+
function countCurrName(rootNode, name) {
72+
if (rootNode.name > name) {
73+
return 0;
74+
}
75+
if (rootNode.name === name) {
76+
return 1;
77+
}
78+
let branch = 0;
79+
rootNode.children.forEach(child => {
80+
branch += countCurrName(child, name);
81+
});
82+
return branch;
83+
}
84+
6785
// Adds a new node to the current location.
6886
// Invoked in the case 'recordSnap'.
6987
function sendToHierarchy(tabObj, newNode) {
@@ -79,23 +97,11 @@ function sendToHierarchy(tabObj, newNode) {
7997
}
8098
}
8199

82-
function countCurrName(rootNode, name) {
83-
if (rootNode.name > name) {
84-
return 0;
85-
}
86-
if (rootNode.name === name) {
87-
return 1;
88-
}
89-
let branch = 0;
90-
rootNode.children.forEach(child => {
91-
branch += countCurrName(child, name);
92-
});
93-
return branch;
94-
}
95-
96100
// This function is used when time jumping to a previous state,
97101
// so that it runs recursively until it finds the correct index,
98102
// and updates the tabsObject to the node at that index.
103+
/* eslint no-param-reassign: ["error", { "props": false }] */
104+
99105
function changeCurrLocation(tabObj, rootNode, index, name) {
100106
// index comes from the app's main reducer to locate the correct current location on tabObj
101107
// check if current node has the index wanted

tsconfig.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"compilerOptions": {
33
"outDir": "./src/extension/build/bundles/",
44
"module": "es6",
5-
//"noImplicitAny": true,
5+
// "noImplicitAny": true,
66
"target": "es5",
77
"jsx": "react",
88
"removeComments": true,

0 commit comments

Comments
 (0)