Skip to content

Commit d9c7f0f

Browse files
committed
chore: fix linting issues and code style
1 parent 8b59a5b commit d9c7f0f

18 files changed

Lines changed: 193 additions & 118 deletions

File tree

.logs/start/react-dev.log

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,53 @@ Note that the development build is not optimized.
1919
To create a production build, use npm run build.
2020

2121
webpack compiled successfully
22+
Compiling...
23+
Compiled successfully!
24+
webpack compiled successfully
25+
Compiling...
26+
Compiled with warnings.
27+
28+
[eslint]
29+
src/views/FilesManager.js
30+
Line 81:31: Function declared in a loop contains unsafe references to variable(s) 'current' no-loop-func
31+
Line 424:27: Function declared in a loop contains unsafe references to variable(s) 'curr' no-loop-func
32+
Line 776:32: Function declared in a loop contains unsafe references to variable(s) 'descendantSizeKb', 'descendantSizeKb', 'descendantSizeKb', 'descendantSizeKb' no-loop-func
33+
Line 1073:6: React Hook useEffect has missing dependencies: 'finishCreateFolder', 'finishRename', 'handleCopy', 'handleCut', 'handleDelete', and 'handlePaste'. Either include them or remove the dependency array react-hooks/exhaustive-deps
34+
35+
src/views/Views.js
36+
Line 11:3: 'BarChartOutlined' is defined but never used no-unused-vars
37+
38+
src/views/mask-proofreading/MaskProofreading.js
39+
Line 5:10: 'ehToolSession' is assigned a value but never used no-unused-vars
40+
Line 5:25: 'setEhToolSession' is assigned a value but never used no-unused-vars
41+
Line 6:10: 'refreshTrigger' is assigned a value but never used no-unused-vars
42+
Line 6:26: 'setRefreshTrigger' is assigned a value but never used no-unused-vars
43+
44+
src/views/project-manager/VolumeTracker.js
45+
Line 126:6: React Hook useMemo has an unnecessary dependency: 'isAdmin'. Either exclude it or remove the dependency array react-hooks/exhaustive-deps
46+
Line 183:15: 'cfg' is assigned a value but never used no-unused-vars
47+
48+
Search for the keywords to learn more about each warning.
49+
To ignore, add // eslint-disable-next-line to the line before.
50+
51+
WARNING in [eslint]
52+
src/views/FilesManager.js
53+
Line 81:31: Function declared in a loop contains unsafe references to variable(s) 'current' no-loop-func
54+
Line 424:27: Function declared in a loop contains unsafe references to variable(s) 'curr' no-loop-func
55+
Line 776:32: Function declared in a loop contains unsafe references to variable(s) 'descendantSizeKb', 'descendantSizeKb', 'descendantSizeKb', 'descendantSizeKb' no-loop-func
56+
Line 1073:6: React Hook useEffect has missing dependencies: 'finishCreateFolder', 'finishRename', 'handleCopy', 'handleCut', 'handleDelete', and 'handlePaste'. Either include them or remove the dependency array react-hooks/exhaustive-deps
57+
58+
src/views/Views.js
59+
Line 11:3: 'BarChartOutlined' is defined but never used no-unused-vars
60+
61+
src/views/mask-proofreading/MaskProofreading.js
62+
Line 5:10: 'ehToolSession' is assigned a value but never used no-unused-vars
63+
Line 5:25: 'setEhToolSession' is assigned a value but never used no-unused-vars
64+
Line 6:10: 'refreshTrigger' is assigned a value but never used no-unused-vars
65+
Line 6:26: 'setRefreshTrigger' is assigned a value but never used no-unused-vars
66+
67+
src/views/project-manager/VolumeTracker.js
68+
Line 126:6: React Hook useMemo has an unnecessary dependency: 'isAdmin'. Either exclude it or remove the dependency array react-hooks/exhaustive-deps
69+
Line 183:15: 'cfg' is assigned a value but never used no-unused-vars
70+
71+
webpack compiled with 1 warning

client/preload.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@ const { contextBridge, ipcRenderer } = require("electron");
22

33
contextBridge.exposeInMainWorld("electronAPI", {
44
isElectron: true,
5-
openLocalFile: (options = {}) => ipcRenderer.invoke("open-local-file", options),
5+
openLocalFile: (options = {}) =>
6+
ipcRenderer.invoke("open-local-file", options),
67
revealInFinder: (targetPath) =>
78
ipcRenderer.invoke("reveal-in-finder", targetPath),
89
});

client/src/configSchema.test.js

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
1-
import {
2-
applyInputPaths,
3-
setInferenceExecutionDefaults,
4-
} from "./configSchema";
1+
import { applyInputPaths, setInferenceExecutionDefaults } from "./configSchema";
52

63
describe("setInferenceExecutionDefaults", () => {
74
it("preserves existing legacy GPU values", () => {

client/src/contexts/GlobalContext.js

Lines changed: 5 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -130,25 +130,13 @@ export const ContextWrapper = (props) => {
130130
const [inferenceConfigOriginPath, setInferenceConfigOriginPath] =
131131
usePersistedState("inferenceConfigOriginPath", "");
132132
const [trainingUploadedYamlFile, setTrainingUploadedYamlFile] =
133-
usePersistedState(
134-
"trainingUploadedYamlFile",
135-
"",
136-
);
133+
usePersistedState("trainingUploadedYamlFile", "");
137134
const [inferenceUploadedYamlFile, setInferenceUploadedYamlFile] =
138-
usePersistedState(
139-
"inferenceUploadedYamlFile",
140-
"",
141-
);
135+
usePersistedState("inferenceUploadedYamlFile", "");
142136
const [trainingSelectedYamlPreset, setTrainingSelectedYamlPreset] =
143-
usePersistedState(
144-
"trainingSelectedYamlPreset",
145-
"",
146-
);
137+
usePersistedState("trainingSelectedYamlPreset", "");
147138
const [inferenceSelectedYamlPreset, setInferenceSelectedYamlPreset] =
148-
usePersistedState(
149-
"inferenceSelectedYamlPreset",
150-
"",
151-
);
139+
usePersistedState("inferenceSelectedYamlPreset", "");
152140
const [imageFileList, setImageFileList] = usePersistedState(
153141
"imageFileList",
154142
[],
@@ -170,10 +158,7 @@ export const ContextWrapper = (props) => {
170158
null,
171159
);
172160
const [inferenceCheckpointPath, setInferenceCheckpointPath] =
173-
usePersistedState(
174-
"inferenceCheckpointPath",
175-
null,
176-
);
161+
usePersistedState("inferenceCheckpointPath", null);
177162
const [currentImage, setCurrentImage] = usePersistedState(
178163
"currentImage",
179164
null,

client/src/services/data_reader.js

Lines changed: 23 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,11 @@
55
* by taskId, abstracting away file paths and backend specifics.
66
*/
77

8-
import axios from 'axios';
8+
import axios from "axios";
99

1010
// Backend configuration
11-
const API_BASE = process.env.REACT_APP_API_URL || 'http://localhost:4242/api/pm';
11+
const API_BASE =
12+
process.env.REACT_APP_API_URL || "http://localhost:4242/api/pm";
1213

1314
class DataReaderService {
1415
/**
@@ -20,7 +21,7 @@ class DataReaderService {
2021
const response = await axios.get(`${API_BASE}/volumes`, { params });
2122
return response.data; // { total, page, items, ... }
2223
} catch (error) {
23-
console.error('Error fetching pooled volumes:', error);
24+
console.error("Error fetching pooled volumes:", error);
2425
throw error;
2526
}
2627
}
@@ -29,29 +30,33 @@ class DataReaderService {
2930
* Get metadata for a specific volume by taskId
3031
*/
3132
async getVolumeByTaskId(taskId) {
32-
try {
33-
// Since the backend uses id as taskId (e.g. vol_001_em.h5)
34-
// we can just use the volumes endpoint with filtering if supported,
35-
// or we could add a dedicated GET /volumes/{id} if needed.
36-
// For now, we'll assume the frontend already has the list or we fetch one.
37-
const response = await axios.get(`${API_BASE}/volumes`, { params: { id: taskId, page_size: 1 } });
38-
return response.data.items[0] || null;
39-
} catch (error) {
40-
console.error(`Error fetching volume ${taskId}:`, error);
41-
throw error;
42-
}
33+
try {
34+
// Since the backend uses id as taskId (e.g. vol_001_em.h5)
35+
// we can just use the volumes endpoint with filtering if supported,
36+
// or we could add a dedicated GET /volumes/{id} if needed.
37+
// For now, we'll assume the frontend already has the list or we fetch one.
38+
const response = await axios.get(`${API_BASE}/volumes`, {
39+
params: { id: taskId, page_size: 1 },
40+
});
41+
return response.data.items[0] || null;
42+
} catch (error) {
43+
console.error(`Error fetching volume ${taskId}:`, error);
44+
throw error;
45+
}
4346
}
4447

4548
/**
4649
* Update volume status by taskId
4750
*/
4851
async updateStatus(taskId, status) {
4952
try {
50-
const response = await axios.patch(`${API_BASE}/volumes/${taskId}`, { status });
53+
const response = await axios.patch(`${API_BASE}/volumes/${taskId}`, {
54+
status,
55+
});
5156
return response.data;
5257
} catch (error) {
53-
console.error(`Error updating volume ${taskId}:`, error);
54-
throw error;
58+
console.error(`Error updating volume ${taskId}:`, error);
59+
throw error;
5560
}
5661
}
5762

@@ -63,7 +68,7 @@ class DataReaderService {
6368
const response = await axios.post(`${API_BASE}/data/link`, { path });
6469
return response.data;
6570
} catch (error) {
66-
console.error('Error linking external metadata:', error);
71+
console.error("Error linking external metadata:", error);
6772
throw error;
6873
}
6974
}

client/src/views/FilesManager.js

Lines changed: 20 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -240,11 +240,14 @@ function FilesManager() {
240240
const normalizedParent = String(parentKey || "root");
241241
const previousFolders = foldersRef.current;
242242
const previousFiles = filesRef.current;
243-
const { folders: nextFolders, files: nextFiles } = transformFiles(fileList);
243+
const { folders: nextFolders, files: nextFiles } =
244+
transformFiles(fileList);
244245
const existingDirectChildIds = previousFolders
245246
.filter((folder) => folder.parent === normalizedParent)
246247
.map((folder) => folder.key);
247-
const nextDirectChildIds = new Set(nextFolders.map((folder) => folder.key));
248+
const nextDirectChildIds = new Set(
249+
nextFolders.map((folder) => folder.key),
250+
);
248251
const removedFolderIds = collectDescendantFolderIds(
249252
previousFolders,
250253
existingDirectChildIds.filter((id) => !nextDirectChildIds.has(id)),
@@ -253,14 +256,19 @@ function FilesManager() {
253256
const mergedFolders = [
254257
...previousFolders.filter(
255258
(folder) =>
256-
folder.parent !== normalizedParent && !removedFolderIds.has(folder.key),
259+
folder.parent !== normalizedParent &&
260+
!removedFolderIds.has(folder.key),
257261
),
258262
...nextFolders,
259263
].sort((left, right) => {
260264
if (left.parent === right.parent) {
261-
return String(left.title || "").localeCompare(String(right.title || ""));
265+
return String(left.title || "").localeCompare(
266+
String(right.title || ""),
267+
);
262268
}
263-
return String(left.parent || "").localeCompare(String(right.parent || ""));
269+
return String(left.parent || "").localeCompare(
270+
String(right.parent || ""),
271+
);
264272
});
265273

266274
const mergedFiles = { ...previousFiles };
@@ -362,11 +370,7 @@ function FilesManager() {
362370
setParentLoadingState(normalizedParent, false);
363371
}
364372
},
365-
[
366-
hasShownServerWarning,
367-
replaceFolderChildren,
368-
setParentLoadingState,
369-
],
373+
[hasShownServerWarning, replaceFolderChildren, setParentLoadingState],
370374
);
371375

372376
// Load initial data with proper cleanup and 401 handling
@@ -1817,12 +1821,12 @@ function FilesManager() {
18171821
currentFolders.length === 0 &&
18181822
currentFiles.length === 0 &&
18191823
!newItemType && (
1820-
<div
1821-
style={{ width: "100%", marginTop: 64, pointerEvents: "none" }}
1822-
>
1823-
<Empty description="Empty Folder" />
1824-
</div>
1825-
)}
1824+
<div
1825+
style={{ width: "100%", marginTop: 64, pointerEvents: "none" }}
1826+
>
1827+
<Empty description="Empty Folder" />
1828+
</div>
1829+
)}
18261830
{currentFolders.map((f) => renderItem(f, "folder"))}
18271831
{renderNewFolderPlaceholder()}
18281832
{currentFiles.map((f) => renderItem(f, "file"))}

client/src/views/FilesManager.test.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,13 @@ jest.mock("@ant-design/icons", () => {
4343
jest.mock("antd", () => {
4444
const React = require("react");
4545

46-
const Button = ({ children, ...props }) => <button {...props}>{children}</button>;
46+
const Button = ({ children, ...props }) => (
47+
<button {...props}>{children}</button>
48+
);
4749
const Dropdown = ({ children }) => <div>{children}</div>;
48-
const Input = React.forwardRef((props, ref) => <input ref={ref} {...props} />);
50+
const Input = React.forwardRef((props, ref) => (
51+
<input ref={ref} {...props} />
52+
));
4953
const Menu = ({ items = [], onClick }) => (
5054
<div>
5155
{items.map((item) =>

client/src/views/Views.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ function Views() {
5656
const [viewers, setViewers] = useState([]);
5757
const [isInferring, setIsInferring] = useState(false);
5858

59-
/*
59+
/*
6060
const allItems = [
6161
{ label: "File Management", key: "files", icon: <FolderOpenOutlined /> },
6262
{ label: "Visualization", key: "visualization", icon: <EyeOutlined /> },
@@ -181,7 +181,7 @@ function Views() {
181181
{/* {renderTabContent("synanno", <ProofReading />)} */}
182182
{/* {renderTabContent("worm-error-handling", <WormErrorHandling />)} */}
183183
{renderTabContent("project-manager", <ProjectManager />)}
184-
</Content >
184+
</Content>
185185
<Drawer
186186
placement="right"
187187
open={isChatOpen}
@@ -214,7 +214,7 @@ function Views() {
214214
/>
215215
<Chatbot onClose={() => setIsChatOpen(false)} />
216216
</Drawer>
217-
</Layout >
217+
</Layout>
218218
);
219219
}
220220

client/src/views/Views.test.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,9 @@ jest.mock("./Visualization", () => () => <div>Visualization Content</div>);
4949
jest.mock("./ModelTraining", () => () => <div>Training Content</div>);
5050
jest.mock("./ModelInference", () => () => <div>Inference Content</div>);
5151
jest.mock("./Monitoring", () => () => <div>Monitoring Content</div>);
52-
jest.mock("./MaskProofreading", () => () => <div>Mask Proofreading Content</div>);
52+
jest.mock("./MaskProofreading", () => () => (
53+
<div>Mask Proofreading Content</div>
54+
));
5355
jest.mock("../components/Chatbot", () => () => <div>Chatbot</div>);
5456

5557
describe("Views", () => {

client/src/views/mask-proofreading/MaskProofreading.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,9 @@ function MaskProofreading() {
1616
setRefreshTrigger((prev) => prev + 1);
1717
}}
1818
/> */}
19-
<div style={{ padding: 20 }}>Mask Proofreading Component (EHTool is currently disabled)</div>
19+
<div style={{ padding: 20 }}>
20+
Mask Proofreading Component (EHTool is currently disabled)
21+
</div>
2022
</div>
2123
);
2224
}

0 commit comments

Comments
 (0)