Skip to content

Commit b2b8d88

Browse files
committed
style: format code with Prettier
- Auto-fix formatting issues in 6 files - Ensure code style consistency across the codebase
1 parent 39bae60 commit b2b8d88

File tree

6 files changed

+88
-76
lines changed

6 files changed

+88
-76
lines changed

src/client/components/HealthCheckStatus.css

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,4 +73,3 @@
7373
.health-check-dead .health-check-icon {
7474
color: var(--color-terminal-red);
7575
}
76-

src/client/components/HealthCheckStatus.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,4 +92,3 @@ export function HealthCheckStatus({
9292
</span>
9393
);
9494
}
95-

src/client/components/HistoryList.tsx

Lines changed: 69 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ function HistoryExportButtonWrapper({
3838
try {
3939
// Get data to export - use existing exportData or fetch from API
4040
let dataToExport = exportData;
41-
41+
4242
if (!dataToExport) {
4343
setIsLoading(true);
4444
try {
@@ -48,10 +48,10 @@ function HistoryExportButtonWrapper({
4848
throw new Error('Failed to fetch results');
4949
}
5050
const data = await response.json();
51-
51+
5252
// Also trigger parent's loadResults to update state
5353
await onLoadResults();
54-
54+
5555
// Extract all results from the response
5656
const allResults: unknown[] = [];
5757
data.forEach((result: { result_data?: unknown }) => {
@@ -230,7 +230,7 @@ export function HistoryList({ history, onDelete, onRefresh }: HistoryListProps)
230230
// Extract hosts from result data
231231
const extractHostsFromResult = useCallback((resultData: unknown): string[] => {
232232
const hosts: string[] = [];
233-
233+
234234
if (resultData && typeof resultData === 'object' && resultData !== null) {
235235
if ('results' in resultData && Array.isArray(resultData.results)) {
236236
resultData.results.forEach((row: unknown) => {
@@ -239,17 +239,15 @@ export function HistoryList({ history, onDelete, onRefresh }: HistoryListProps)
239239
hostValue = String(row[0] ?? '').trim();
240240
} else if (typeof row === 'object' && row !== null) {
241241
const rowObj = row as Record<string, unknown>;
242-
hostValue = String(
243-
rowObj.host ?? rowObj.HOST ?? rowObj.Host ?? rowObj[0] ?? ''
244-
).trim();
242+
hostValue = String(rowObj.host ?? rowObj.HOST ?? rowObj.Host ?? rowObj[0] ?? '').trim();
245243
}
246244
if (hostValue && !hosts.includes(hostValue)) {
247245
hosts.push(hostValue);
248246
}
249247
});
250248
}
251249
}
252-
250+
253251
return hosts;
254252
}, []);
255253

@@ -283,7 +281,7 @@ export function HistoryList({ history, onDelete, onRefresh }: HistoryListProps)
283281
const batch = hosts.slice(i, i + batchSize);
284282
const batchResults = await checkHostsHealth(batch, { timeout: 5000 });
285283

286-
batchResults.forEach((checkResult) => {
284+
batchResults.forEach(checkResult => {
287285
resultsMap[checkResult.host] = checkResult;
288286
if (checkResult.alive) {
289287
aliveCount++;
@@ -425,15 +423,21 @@ export function HistoryList({ history, onDelete, onRefresh }: HistoryListProps)
425423
{checkSummary[item.id] && (
426424
<div className="query-results-summary">
427425
<div className="summary-item summary-total">
428-
<span className="summary-label">{t('query.results.summary.total')}:</span>
426+
<span className="summary-label">
427+
{t('query.results.summary.total')}:
428+
</span>
429429
<span className="summary-value">{checkSummary[item.id].total}</span>
430430
</div>
431431
<div className="summary-item summary-alive">
432-
<span className="summary-label">{t('query.results.summary.alive')}:</span>
432+
<span className="summary-label">
433+
{t('query.results.summary.alive')}:
434+
</span>
433435
<span className="summary-value">{checkSummary[item.id].alive}</span>
434436
</div>
435437
<div className="summary-item summary-dead">
436-
<span className="summary-label">{t('query.results.summary.dead')}:</span>
438+
<span className="summary-label">
439+
{t('query.results.summary.dead')}:
440+
</span>
437441
<span className="summary-value">{checkSummary[item.id].dead}</span>
438442
</div>
439443
</div>
@@ -444,7 +448,8 @@ export function HistoryList({ history, onDelete, onRefresh }: HistoryListProps)
444448
<thead>
445449
<tr>
446450
{(() => {
447-
const resultsArray = (resultData as { results: unknown[] }).results;
451+
const resultsArray = (resultData as { results: unknown[] })
452+
.results;
448453
const firstResult = resultsArray[0];
449454
if (Array.isArray(firstResult)) {
450455
return (
@@ -473,56 +478,60 @@ export function HistoryList({ history, onDelete, onRefresh }: HistoryListProps)
473478
</tr>
474479
</thead>
475480
<tbody>
476-
{(resultData as { results: unknown[] }).results.map((row: unknown, rowIdx: number) => {
477-
let hostValue = '';
478-
if (Array.isArray(row) && row.length > 0) {
479-
hostValue = String(row[0] ?? '').trim();
480-
} else if (typeof row === 'object' && row !== null) {
481-
const rowObj = row as Record<string, unknown>;
482-
hostValue = String(
483-
rowObj.host ?? rowObj.HOST ?? rowObj.Host ?? rowObj[0] ?? ''
484-
).trim();
485-
}
481+
{(resultData as { results: unknown[] }).results.map(
482+
(row: unknown, rowIdx: number) => {
483+
let hostValue = '';
484+
if (Array.isArray(row) && row.length > 0) {
485+
hostValue = String(row[0] ?? '').trim();
486+
} else if (typeof row === 'object' && row !== null) {
487+
const rowObj = row as Record<string, unknown>;
488+
hostValue = String(
489+
rowObj.host ?? rowObj.HOST ?? rowObj.Host ?? rowObj[0] ?? ''
490+
).trim();
491+
}
486492

487-
if (Array.isArray(row)) {
488-
return (
489-
<tr key={rowIdx}>
490-
{row.map((cell: unknown, cellIdx: number) => (
491-
<td key={cellIdx}>{String(cell ?? '-')}</td>
492-
))}
493-
<td className="health-check-cell">
494-
{hostValue ? (
495-
<HealthCheckStatus
496-
host={hostValue}
497-
externalResult={checkResults[item.id]?.[hostValue]}
498-
/>
499-
) : (
500-
'-'
501-
)}
502-
</td>
503-
</tr>
504-
);
505-
} else if (typeof row === 'object' && row !== null) {
506-
return (
507-
<tr key={rowIdx}>
508-
{Object.values(row).map((cell: unknown, cellIdx: number) => (
509-
<td key={cellIdx}>{String(cell ?? '-')}</td>
510-
))}
511-
<td className="health-check-cell">
512-
{hostValue ? (
513-
<HealthCheckStatus
514-
host={hostValue}
515-
externalResult={checkResults[item.id]?.[hostValue]}
516-
/>
517-
) : (
518-
'-'
493+
if (Array.isArray(row)) {
494+
return (
495+
<tr key={rowIdx}>
496+
{row.map((cell: unknown, cellIdx: number) => (
497+
<td key={cellIdx}>{String(cell ?? '-')}</td>
498+
))}
499+
<td className="health-check-cell">
500+
{hostValue ? (
501+
<HealthCheckStatus
502+
host={hostValue}
503+
externalResult={checkResults[item.id]?.[hostValue]}
504+
/>
505+
) : (
506+
'-'
507+
)}
508+
</td>
509+
</tr>
510+
);
511+
} else if (typeof row === 'object' && row !== null) {
512+
return (
513+
<tr key={rowIdx}>
514+
{Object.values(row).map(
515+
(cell: unknown, cellIdx: number) => (
516+
<td key={cellIdx}>{String(cell ?? '-')}</td>
517+
)
519518
)}
520-
</td>
521-
</tr>
522-
);
519+
<td className="health-check-cell">
520+
{hostValue ? (
521+
<HealthCheckStatus
522+
host={hostValue}
523+
externalResult={checkResults[item.id]?.[hostValue]}
524+
/>
525+
) : (
526+
'-'
527+
)}
528+
</td>
529+
</tr>
530+
);
531+
}
532+
return null;
523533
}
524-
return null;
525-
})}
534+
)}
526535
</tbody>
527536
</table>
528537
</div>

src/client/components/QueryResults.tsx

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,11 @@ export function QueryResults({ result, tab }: QueryResultsProps) {
1818
const [checkingAll, setCheckingAll] = useState(false);
1919
const [checkProgress, setCheckProgress] = useState({ current: 0, total: 0 });
2020
const [checkResults, setCheckResults] = useState<Record<string, HealthCheckResult>>({});
21-
const [checkSummary, setCheckSummary] = useState<{ total: number; alive: number; dead: number } | null>(null);
21+
const [checkSummary, setCheckSummary] = useState<{
22+
total: number;
23+
alive: number;
24+
dead: number;
25+
} | null>(null);
2226

2327
// Extract all hosts from results - must be before early returns
2428
const extractHosts = useCallback((): string[] => {
@@ -33,9 +37,7 @@ export function QueryResults({ result, tab }: QueryResultsProps) {
3337
hostValue = String(row[0] ?? '').trim();
3438
} else if (typeof row === 'object' && row !== null) {
3539
const rowObj = row as Record<string, unknown>;
36-
hostValue = String(
37-
rowObj.host ?? rowObj.HOST ?? rowObj.Host ?? rowObj[0] ?? ''
38-
).trim();
40+
hostValue = String(rowObj.host ?? rowObj.HOST ?? rowObj.Host ?? rowObj[0] ?? '').trim();
3941
}
4042
if (hostValue && !hosts.includes(hostValue)) {
4143
hosts.push(hostValue);
@@ -88,7 +90,7 @@ export function QueryResults({ result, tab }: QueryResultsProps) {
8890
const batch = hosts.slice(i, i + batchSize);
8991
const batchResults = await checkHostsHealth(batch, { timeout: 5000 });
9092

91-
batchResults.forEach((checkResult) => {
93+
batchResults.forEach(checkResult => {
9294
resultsMap[checkResult.host] = checkResult;
9395
if (checkResult.alive) {
9496
aliveCount++;
@@ -147,7 +149,9 @@ export function QueryResults({ result, tab }: QueryResultsProps) {
147149
>
148150
{copied ? t('common.copied') : t('query.results.copyJson')}
149151
</button>
150-
{'results' in result && Array.isArray(result.results) && result.results.length > 0 ? (
152+
{'results' in result &&
153+
Array.isArray(result.results) &&
154+
result.results.length > 0 ? (
151155
<button
152156
className="btn-secondary btn-check-all"
153157
onClick={handleCheckAll}
@@ -213,8 +217,9 @@ export function QueryResults({ result, tab }: QueryResultsProps) {
213217
hostValue = String(row[0] ?? '');
214218
} else if (typeof row === 'object' && row !== null) {
215219
const rowObj = row as Record<string, unknown>;
216-
hostValue =
217-
String(rowObj.host ?? rowObj.HOST ?? rowObj.Host ?? rowObj[0] ?? '');
220+
hostValue = String(
221+
rowObj.host ?? rowObj.HOST ?? rowObj.Host ?? rowObj[0] ?? ''
222+
);
218223
}
219224

220225
if (Array.isArray(row)) {

src/client/pages/HistoryPage.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,12 @@ export function HistoryPage() {
1515
setLoading(true);
1616
setError(null);
1717
const response = await fetch('/api/history?limit=100');
18-
18+
1919
if (!response.ok) {
2020
const errorData = await response.json().catch(() => ({ error: 'Unknown error' }));
2121
throw new Error(errorData.error || t('errors.failedToLoad'));
2222
}
23-
23+
2424
const data = await response.json();
2525
setHistory(data.history || []);
2626
} catch (error) {

src/server/services/healthcheck.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,8 @@ export async function checkHostHealth(
5050
}
5151

5252
const finalPort = defaultPort || (protocol === 'https' ? 443 : 80);
53-
const finalProtocol = defaultPort === 443 || (!defaultPort && protocol === 'https') ? 'https' : 'http';
53+
const finalProtocol =
54+
defaultPort === 443 || (!defaultPort && protocol === 'https') ? 'https' : 'http';
5455
const url = `${finalProtocol}://${hostname}${finalPort && finalPort !== 80 && finalPort !== 443 ? `:${finalPort}` : ''}`;
5556

5657
const startTime = Date.now();
@@ -84,7 +85,7 @@ export async function checkHostHealth(
8485
try {
8586
const net = await import('node:net');
8687
const socket = new net.Socket();
87-
const tcpAlive = await new Promise<boolean>((resolve) => {
88+
const tcpAlive = await new Promise<boolean>(resolve => {
8889
const tcpTimeout = setTimeout(() => {
8990
socket.destroy();
9091
resolve(false);
@@ -126,7 +127,6 @@ export async function checkHostsHealth(
126127
hosts: string[],
127128
options: HealthCheckOptions = {}
128129
): Promise<HealthCheckResult[]> {
129-
const checks = hosts.map((host) => checkHostHealth(host, options));
130+
const checks = hosts.map(host => checkHostHealth(host, options));
130131
return Promise.all(checks);
131132
}
132-

0 commit comments

Comments
 (0)