Skip to content

Commit 3626e49

Browse files
committed
fix: apply remaining Biome lint fixes and CSS positioning fix
- Fix non-null assertion in AutoStartSimulation.tsx - Fix template literals and hook dependencies in Figure.tsx - Fix isFinite usage in ColorLegend.tsx - Add button types to ResponsiveSimulationSummary.test.tsx - Fix accessibility in Figure.test.tsx - Apply Biome auto-fixes across codebase (formatting, imports, etc.) - Fix CSS positioning issue with simulation summary overlay
1 parent d4bbbd5 commit 3626e49

27 files changed

Lines changed: 98 additions & 104 deletions

src/App.test.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import React from "react";
21
import { createRoot } from "react-dom/client";
32
import { describe, it } from "vitest";
43
import App from "./App";

src/App.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ const App: React.FC = () => {
114114
setCollapsed(false);
115115
}
116116
}, [width]);
117-
const editMenuLabel = "Edit " + (simulation ? simulation?.id : "");
117+
const editMenuLabel = `Edit ${simulation ? simulation?.id : ""}`;
118118
const runStopButtonTitle = running ? "Stop" : "Run";
119119

120120
const runStopButton = getItem(
@@ -190,7 +190,7 @@ const App: React.FC = () => {
190190
<EditOutlined />,
191191
simulation
192192
? simulation.files.map((file) => {
193-
return getItem(file.fileName, "file" + file.fileName, <FileOutlined />);
193+
return getItem(file.fileName, `file${file.fileName}`, <FileOutlined />);
194194
})
195195
: [],
196196
undefined,
@@ -228,7 +228,7 @@ const App: React.FC = () => {
228228

229229
useEffect(() => {
230230
if (selectedFile) {
231-
setSelectedMenu("file" + selectedFile.fileName);
231+
setSelectedMenu(`file${selectedFile.fileName}`);
232232
}
233233
}, [selectedFile, setSelectedMenu]);
234234

src/components/AutoStartSimulation.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,18 +53,18 @@ const AutoStartSimulation: React.FC = () => {
5353
if (autoStart) {
5454
setPreferredView("view"); // Visualizer showing atoms
5555
} else {
56-
setPreferredView("file" + decodedSimulation.inputScript); // Editor with script
56+
setPreferredView(`file${decodedSimulation.inputScript}`); // Editor with script
5757
}
5858
}
5959
return;
6060
}
6161

6262
// Handle URL-based embedding (only in embedded mode)
63-
if (!isEmbeddedMode) {
63+
if (!isEmbeddedMode || !embeddedSimulationUrl) {
6464
return;
6565
}
6666

67-
const response = await fetch(embeddedSimulationUrl!);
67+
const response = await fetch(embeddedSimulationUrl);
6868
const data: ExamplesData = await response.json();
6969

7070
// Override baseUrl for localhost development

src/components/ColorLegend.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ const ColorLegend = ({
5656
}, [colormapName]);
5757

5858
const formatValue = (value: number): string => {
59-
if (!isFinite(value)) {
59+
if (!Number.isFinite(value)) {
6060
return "N/A";
6161
}
6262
// Format to 3 significant figures

src/components/Figure.tsx

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ const Figure = ({
3232
onToggleSyncDataPoints,
3333
}: FigureProps) => {
3434
const [graph, setGraph] = useState<Dygraph>();
35-
const timesteps = useStoreState((state) => state.simulationStatus.timesteps);
35+
const _timesteps = useStoreState((state) => state.simulationStatus.timesteps);
3636
const graphId = useId();
3737
const width = window.innerWidth < 1000 ? window.innerWidth * 0.8 : window.innerWidth * 0.6;
3838
const height = (width * 3) / 4;
@@ -47,16 +47,7 @@ const Figure = ({
4747
yLabel: source.yLabel,
4848
name: source.name,
4949
};
50-
}, [
51-
modifier?.name,
52-
modifier?.xLabel,
53-
modifier?.yLabel,
54-
modifier?.data1D,
55-
plotData?.name,
56-
plotData?.xLabel,
57-
plotData?.yLabel,
58-
plotData?.data1D,
59-
]);
50+
}, [modifier, plotData]);
6051

6152
// Only set syncDataPoints when a modifier is provided
6253
// Use ref to track previous modifier name to detect actual changes
@@ -112,8 +103,8 @@ const Figure = ({
112103
data.series.forEach((series) => {
113104
if (!series.isVisible) return;
114105
const color = series.color;
115-
html += '<span class="dygraph-legend-dot" style="color: ' + color + ';">● </span>';
116-
html += series.labelHTML + ": " + series.yHTML + "<br/>";
106+
html += `<span class="dygraph-legend-dot" style="color: ${color};">● </span>`;
107+
html += `${series.labelHTML}: ${series.yHTML}<br/>`;
117108
});
118109
html += "</div>";
119110
return html;
@@ -127,7 +118,7 @@ const Figure = ({
127118
if (graph && plotConfig?.data1D) {
128119
graph.updateOptions({ file: plotConfig.data1D.data });
129120
}
130-
}, [graph, plotConfig, timesteps]);
121+
}, [graph, plotConfig]);
131122

132123
return (
133124
<Modal open width={width} footer={null} onCancel={onClose}>

src/components/ResponsiveSimulationSummary.test.tsx

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,18 @@ vi.mock("./SimulationSummary", () => ({
1717
}: ComponentProps<typeof SimulationSummary>) => (
1818
<div data-testid="simulation-summary">
1919
{isCollapsed && <div data-testid="collapsed">Collapsed</div>}
20-
{onShowMore && <button data-testid="expand-button">Expand</button>}
20+
{onShowMore && (
21+
<button type="button" data-testid="expand-button">
22+
Expand
23+
</button>
24+
)}
2125
{onExpand && (
22-
<button data-testid="expand-handler" onClick={onExpand}>
26+
<button type="button" data-testid="expand-handler" onClick={onExpand}>
2327
Expand Handler
2428
</button>
2529
)}
2630
{onCollapse && (
27-
<button data-testid="collapse-handler" onClick={onCollapse}>
31+
<button type="button" data-testid="collapse-handler" onClick={onCollapse}>
2832
Collapse Handler
2933
</button>
3034
)}
@@ -36,7 +40,7 @@ vi.mock("./SimulationSummaryExpanded", () => ({
3640
default: ({ onShowLess }: ComponentProps<typeof SimulationSummaryExpanded>) => (
3741
<div data-testid="simulation-summary-expanded">
3842
{onShowLess && (
39-
<button data-testid="show-less-button" onClick={onShowLess}>
43+
<button type="button" data-testid="show-less-button" onClick={onShowLess}>
4044
Show Less
4145
</button>
4246
)}

src/components/SelectedAtomsInfo.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { Button } from "antd";
22
import type { Particles } from "omovi";
33
import { useEffect, useMemo, useRef, useState } from "react";
44
import { useStoreState } from "../hooks";
5-
import { type Data1D, PlotData } from "../types";
5+
import type { Data1D } from "../types";
66
import Figure from "./Figure";
77

88
interface SelectedAtomsInfoProps {

src/components/SimulationSummaryContent.tsx

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ const SimulationSummaryContent = () => {
109109
>
110110
{value}
111111
</Button>{" "}
112-
{" " + (record.hasScalarData ? record.scalarValue.toPrecision(5).toString() : "")}
112+
{` ${record.hasScalarData ? record.scalarValue.toPrecision(5).toString() : ""}`}
113113
</>
114114
);
115115
} else {
@@ -144,7 +144,7 @@ const SimulationSummaryContent = () => {
144144
>
145145
{value}
146146
</Button>{" "}
147-
{" " + (record.hasScalarData ? record.scalarValue.toPrecision(5).toString() : "")}
147+
{` ${record.hasScalarData ? record.scalarValue.toPrecision(5).toString() : ""}`}
148148
</>
149149
);
150150
} else {
@@ -179,7 +179,7 @@ const SimulationSummaryContent = () => {
179179
>
180180
{value}
181181
</Button>{" "}
182-
{" " + (record.hasScalarData ? record.scalarValue.toPrecision(5).toString() : "")}
182+
{` ${record.hasScalarData ? record.scalarValue.toPrecision(5).toString() : ""}`}
183183
</>
184184
);
185185
} else {
@@ -200,7 +200,7 @@ const SimulationSummaryContent = () => {
200200
title: "Name",
201201
dataIndex: "name",
202202
key: "name",
203-
render: (text, record) => (
203+
render: (text, _record) => (
204204
<Row justify="space-between">
205205
<Col span={8}>{text}</Col>{" "}
206206
<Col span={2}>
@@ -212,7 +212,7 @@ const SimulationSummaryContent = () => {
212212
];
213213

214214
const rowSelection: TableRowSelection<Modifier> = {
215-
onChange: (selectedRowKeys, selectedRows) => {
215+
onChange: (_selectedRowKeys, selectedRows) => {
216216
modifiers.forEach((modifier) => {
217217
modifier.active = selectedRows.indexOf(modifier) >= 0;
218218
});
@@ -302,7 +302,7 @@ const SimulationSummaryContent = () => {
302302
{
303303
key: "timeremain",
304304
name: "Remaining time",
305-
value: Math.ceil(remainingTime).toString() + " s",
305+
value: `${Math.ceil(remainingTime).toString()} s`,
306306
},
307307
{
308308
key: "tsps",
@@ -312,7 +312,7 @@ const SimulationSummaryContent = () => {
312312
{
313313
key: "memory",
314314
name: "Memory usage",
315-
value: (memoryUsage / 1024 / 1024).toFixed(2).toString() + " MB",
315+
value: `${(memoryUsage / 1024 / 1024).toFixed(2).toString()} MB`,
316316
},
317317
{
318318
key: "simulationspeed",
@@ -341,7 +341,6 @@ const SimulationSummaryContent = () => {
341341
memoryUsage,
342342
simulationSettings.speed,
343343
simulationSettings.uiUpdateFrequency,
344-
renderSettings.showSimulationBox,
345344
]);
346345

347346
return (

src/components/SimulationSummaryExpanded.tsx

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ const SimulationSummaryExpanded = ({ onShowLess }: SimulationSummaryExpandedProp
115115
>
116116
{value}
117117
</Button>{" "}
118-
{" " + (record.hasScalarData ? record.scalarValue.toPrecision(5).toString() : "")}
118+
{` ${record.hasScalarData ? record.scalarValue.toPrecision(5).toString() : ""}`}
119119
</>
120120
);
121121
} else {
@@ -150,7 +150,7 @@ const SimulationSummaryExpanded = ({ onShowLess }: SimulationSummaryExpandedProp
150150
>
151151
{value}
152152
</Button>{" "}
153-
{" " + (record.hasScalarData ? record.scalarValue.toPrecision(5).toString() : "")}
153+
{` ${record.hasScalarData ? record.scalarValue.toPrecision(5).toString() : ""}`}
154154
</>
155155
);
156156
} else {
@@ -185,7 +185,7 @@ const SimulationSummaryExpanded = ({ onShowLess }: SimulationSummaryExpandedProp
185185
>
186186
{value}
187187
</Button>{" "}
188-
{" " + (record.hasScalarData ? record.scalarValue.toPrecision(5).toString() : "")}
188+
{` ${record.hasScalarData ? record.scalarValue.toPrecision(5).toString() : ""}`}
189189
</>
190190
);
191191
} else {
@@ -206,7 +206,7 @@ const SimulationSummaryExpanded = ({ onShowLess }: SimulationSummaryExpandedProp
206206
title: "Name",
207207
dataIndex: "name",
208208
key: "name",
209-
render: (text, record) => (
209+
render: (text, _record) => (
210210
<Row justify="space-between">
211211
<Col span={8}>{text}</Col>{" "}
212212
<Col span={2}>
@@ -218,7 +218,7 @@ const SimulationSummaryExpanded = ({ onShowLess }: SimulationSummaryExpandedProp
218218
];
219219

220220
const rowSelection: TableRowSelection<Modifier> = {
221-
onChange: (selectedRowKeys, selectedRows) => {
221+
onChange: (_selectedRowKeys, selectedRows) => {
222222
modifiers.forEach((modifier) => {
223223
modifier.active = selectedRows.indexOf(modifier) >= 0;
224224
});
@@ -292,7 +292,7 @@ const SimulationSummaryExpanded = ({ onShowLess }: SimulationSummaryExpandedProp
292292
{
293293
key: "timeremain",
294294
name: "Remaining time",
295-
value: Math.ceil(remainingTime).toString() + " s",
295+
value: `${Math.ceil(remainingTime).toString()} s`,
296296
},
297297
{
298298
key: "tsps",
@@ -302,7 +302,7 @@ const SimulationSummaryExpanded = ({ onShowLess }: SimulationSummaryExpandedProp
302302
{
303303
key: "memory",
304304
name: "Memory usage",
305-
value: (memoryUsage / 1024 / 1024).toFixed(2).toString() + " MB",
305+
value: `${(memoryUsage / 1024 / 1024).toFixed(2).toString()} MB`,
306306
},
307307
{
308308
key: "simulationspeed",

src/containers/Console.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ const Console = ({ width, height }: ConsoleProps) => {
2727
editor.revealLine(model.getLineCount());
2828
}
2929
}
30-
}, [lammpsOutput]);
30+
}, []);
3131

3232
const handleEditorDidMount = (editor: Monaco.editor.IStandaloneCodeEditor) => {
3333
editorRef.current = editor;

0 commit comments

Comments
 (0)