style: auto-fix ESLint issues (curly braces and formatting)

- Add curly braces to all if/else/for/while statements
- Fix indentation and trailing spaces
- Auto-fixed 372 linting errors using eslint --fix
- Remaining issues are warnings only (non-null assertions, explicit any types)
This commit is contained in:
William Valentin
2026-02-11 10:30:24 -08:00
parent 0578a87d85
commit 6090508bad
99 changed files with 418 additions and 418 deletions
+1 -1
View File
@@ -80,7 +80,7 @@ function extractQueryToken(req: IncomingMessage): string | undefined {
}
function extractTailscaleIdentity(req: IncomingMessage, config: AuthConfig): string | undefined {
if (!config.tailscaleIdentity) return undefined;
if (!config.tailscaleIdentity) {return undefined;}
const header = req.headers['tailscale-user-login'];
if (typeof header === 'string' && header.length > 0) {
return header;
+6 -6
View File
@@ -18,9 +18,9 @@ export function redactConfig(config: Config): Record<string, unknown> {
// Helper: redact specified keys on an object if they exist and are non-nullish
const redact = (obj: Record<string, unknown> | undefined, ...keys: string[]) => {
if (!obj) return;
if (!obj) {return;}
for (const key of keys) {
if (obj[key] !== undefined && obj[key] !== null) obj[key] = '***';
if (obj[key] !== undefined && obj[key] !== null) {obj[key] = '***';}
}
};
@@ -102,22 +102,22 @@ export function redactConfig(config: Config): Record<string, unknown> {
/** Keys that are safe to update at runtime via config.patch. */
const PATCHABLE_KEYS: Record<string, (config: Config, value: unknown) => boolean> = {
'hooks.confirm': (config, value) => {
if (!Array.isArray(value) || !value.every((v) => typeof v === 'string')) return false;
if (!Array.isArray(value) || !value.every((v) => typeof v === 'string')) {return false;}
config.hooks.confirm = value as string[];
return true;
},
'hooks.log': (config, value) => {
if (!Array.isArray(value) || !value.every((v) => typeof v === 'string')) return false;
if (!Array.isArray(value) || !value.every((v) => typeof v === 'string')) {return false;}
config.hooks.log = value as string[];
return true;
},
'hooks.silent': (config, value) => {
if (!Array.isArray(value) || !value.every((v) => typeof v === 'string')) return false;
if (!Array.isArray(value) || !value.every((v) => typeof v === 'string')) {return false;}
config.hooks.silent = value as string[];
return true;
},
'server.localhost': (config, value) => {
if (typeof value !== 'boolean') return false;
if (typeof value !== 'boolean') {return false;}
config.server.localhost = value;
return true;
},
+1 -1
View File
@@ -16,7 +16,7 @@ export function createSessionHandlers(deps: SessionHandlerDeps) {
id,
messageCount: deps.sessionManager.getSession(
id.split(':')[0],
id.split(':').slice(1).join(':')
id.split(':').slice(1).join(':'),
).getHistory().length,
}));
return makeResponse(request.id, { sessions });
+2 -2
View File
@@ -83,7 +83,7 @@ export class LaneQueue {
*/
cancel(laneId: string): void {
const lane = this.lanes.get(laneId);
if (!lane) return;
if (!lane) {return;}
const pending = lane.queue.splice(0);
for (const entry of pending) {
@@ -102,7 +102,7 @@ export class LaneQueue {
*/
private processNext(laneId: string): void {
const lane = this.lanes.get(laneId);
if (!lane) return;
if (!lane) {return;}
const entry = lane.queue.shift();
if (!entry) {
+2 -2
View File
@@ -109,7 +109,7 @@ export type OutboundMessage = GatewayResponse | GatewayError | GatewayEvent;
// ── Validation helpers ─────────────────────────────────────────
export function isValidRequest(msg: unknown): msg is GatewayRequest {
if (typeof msg !== 'object' || msg === null) return false;
if (typeof msg !== 'object' || msg === null) {return false;}
const obj = msg as Record<string, unknown>;
return (
typeof obj.id === 'number' &&
@@ -121,7 +121,7 @@ export function isValidRequest(msg: unknown): msg is GatewayRequest {
export function parseMessage(raw: string): GatewayRequest | null {
try {
const parsed = JSON.parse(raw);
if (isValidRequest(parsed)) return parsed;
if (isValidRequest(parsed)) {return parsed;}
return null;
} catch {
return null;
+2 -2
View File
@@ -327,7 +327,7 @@ export class GatewayServer {
if (uiDir) {
const served = await serveStatic(req, res, uiDir);
if (served) return;
if (served) {return;}
}
// No UI directory configured, or file not found
@@ -344,7 +344,7 @@ export class GatewayServer {
}
// Inject connectionId into params so handlers can identify the client
if (!request.params) request.params = {};
if (!request.params) {request.params = {};}
request.params.connectionId = connectionId;
const send = (msg: OutboundMessage) => this.send(ws, msg);
+5 -5
View File
@@ -83,8 +83,8 @@ export class SessionBridge {
/** Switch a connection to a different session (e.g. resuming an old session). */
switchSession(connectionId: string, sessionId: string): void {
const client = this.clients.get(connectionId);
if (!client) throw new Error(`Unknown connection: ${connectionId}`);
if (client.busy) throw new Error('Cannot switch session while agent is busy');
if (!client) {throw new Error(`Unknown connection: ${connectionId}`);}
if (client.busy) {throw new Error('Cannot switch session while agent is busy');}
const agent = this.getOrCreateAgent(sessionId);
client.sessionId = sessionId;
@@ -109,13 +109,13 @@ export class SessionBridge {
/** Mark a connection's agent as busy/idle. */
setBusy(connectionId: string, busy: boolean): void {
const client = this.clients.get(connectionId);
if (client) client.busy = busy;
if (client) {client.busy = busy;}
}
/** Set onToolUse callback for a connection's agent. */
setOnToolUse(connectionId: string, callback: ((event: ToolUseEvent) => void) | undefined): void {
const client = this.clients.get(connectionId);
if (client) client.agent.setOnToolUse(callback);
if (client) {client.agent.setOnToolUse(callback);}
}
/** List all active sessions with connection counts. */
@@ -159,7 +159,7 @@ export class SessionBridge {
const seen = new Set<string>();
for (const client of this.clients.values()) {
if (seen.has(client.sessionId)) continue;
if (seen.has(client.sessionId)) {continue;}
seen.add(client.sessionId);
const usage = client.agent.getUsage();
+2 -2
View File
@@ -65,12 +65,12 @@ export function initStatusIndicator() {
client.onStatusChange((status) => {
statusEl.textContent = status === 'connected' ? 'Connected' :
status === 'connecting' ? 'Connecting...' : 'Disconnected';
status === 'connecting' ? 'Connecting...' : 'Disconnected';
statusEl.className = `conn-status ${status}`;
});
// Set initial status
statusEl.textContent = client.status === 'connected' ? 'Connected' :
client.status === 'connecting' ? 'Connecting...' : 'Disconnected';
client.status === 'connecting' ? 'Connecting...' : 'Disconnected';
statusEl.className = `conn-status ${client.status}`;
}
+3 -3
View File
@@ -165,18 +165,18 @@ export class FlynnClient {
const handle = {
on(event, callback) {
if (!events.has(event)) events.set(event, []);
if (!events.has(event)) {events.set(event, []);}
events.get(event).push(callback);
return handle;
},
result: new Promise((resolve, reject) => {
// Auto-wire done/error to resolve/reject the promise
if (!events.has('done')) events.set('done', []);
if (!events.has('done')) {events.set('done', []);}
events.get('done').push((data) => {
this._listeners.delete(id);
resolve(data);
});
if (!events.has('error')) events.set('error', []);
if (!events.has('error')) {events.set('error', []);}
events.get('error').push((data) => {
this._listeners.delete(id);
reject(new Error(data.message || 'Agent error'));
+22 -22
View File
@@ -133,7 +133,7 @@ function createMessageActions(role) {
copyBtn.innerHTML = COPY_ICON;
copyBtn.addEventListener('click', () => {
const msg = bar.closest('.message');
if (!msg) return;
if (!msg) {return;}
const text = getMessageText(msg);
navigator.clipboard.writeText(text).then(() => {
copyBtn.innerHTML = CHECK_ICON;
@@ -154,7 +154,7 @@ function createMessageActions(role) {
editBtn.innerHTML = EDIT_ICON;
editBtn.addEventListener('click', () => {
const msg = bar.closest('.message');
if (!msg) return;
if (!msg) {return;}
const text = getMessageText(msg);
const input = _elements.input;
if (input) {
@@ -177,7 +177,7 @@ function setSearchMode(active) {
_searchMode = active;
const btn = _elements.searchBtn;
const input = _elements.input;
if (!btn || !input) return;
if (!btn || !input) {return;}
if (active) {
btn.classList.add('active');
@@ -198,7 +198,7 @@ function getFilteredCommands(text) {
function showSlashPopup(filtered) {
const popup = _elements.slashPopup;
if (!popup) return;
if (!popup) {return;}
popup.innerHTML = '';
if (filtered.length === 0) {
@@ -225,13 +225,13 @@ function showSlashPopup(filtered) {
function hideSlashPopup() {
const popup = _elements.slashPopup;
if (popup) popup.classList.add('hidden');
if (popup) {popup.classList.add('hidden');}
_slashPopupIndex = -1;
}
function updatePopupSelection(filtered) {
const popup = _elements.slashPopup;
if (!popup) return;
if (!popup) {return;}
const items = popup.querySelectorAll('.slash-popup-item');
items.forEach((el, i) => {
el.classList.toggle('selected', i === _slashPopupIndex);
@@ -240,7 +240,7 @@ function updatePopupSelection(filtered) {
function selectSlashCommand(name) {
const input = _elements.input;
if (!input) return;
if (!input) {return;}
input.value = name;
hideSlashPopup();
input.focus();
@@ -248,14 +248,14 @@ function selectSlashCommand(name) {
function handleSlashPopupInput() {
const input = _elements.input;
if (!input) return;
if (!input) {return;}
const text = input.value;
// Show popup only when text starts with / and is at most a single word (the command itself)
if (text.startsWith('/') && !text.includes(' ')) {
const filtered = getFilteredCommands(text);
// Clamp selection index
if (_slashPopupIndex >= filtered.length) _slashPopupIndex = filtered.length - 1;
if (_slashPopupIndex >= filtered.length) {_slashPopupIndex = filtered.length - 1;}
showSlashPopup(filtered);
} else {
hideSlashPopup();
@@ -266,7 +266,7 @@ function handleSlashPopupInput() {
function parseSlashCommand(text) {
const trimmed = text.trim();
if (!trimmed.startsWith('/')) return null;
if (!trimmed.startsWith('/')) {return null;}
const parts = trimmed.split(/\s+/);
const cmd = parts[0].toLowerCase();
@@ -405,7 +405,7 @@ async function handleSlashCommand(cmd, client) {
async function loadSessions(client) {
const select = _elements.sessionSelect;
if (!select) return;
if (!select) {return;}
try {
const result = await client.call('sessions.list');
@@ -425,7 +425,7 @@ async function loadSessions(client) {
const opt = document.createElement('option');
opt.value = s.id;
opt.textContent = `${s.id} (${s.messageCount} msgs)`;
if (s.id === current) opt.selected = true;
if (s.id === current) {opt.selected = true;}
select.appendChild(opt);
}
}
@@ -439,7 +439,7 @@ async function loadSessions(client) {
async function loadHistory(client) {
const msgs = _elements.messages;
if (!msgs || !_currentSession) return;
if (!msgs || !_currentSession) {return;}
msgs.innerHTML = '';
@@ -464,21 +464,21 @@ async function loadHistory(client) {
async function sendMessage(client, overrideText) {
const input = _elements.input;
const rawText = overrideText ?? input?.value?.trim();
if (!rawText || _sending) return;
if (!rawText || _sending) {return;}
// Check for slash commands first
const cmd = parseSlashCommand(rawText);
if (cmd) {
if (!overrideText) input.value = '';
if (!overrideText) {input.value = '';}
hideSlashPopup();
const handled = await handleSlashCommand(cmd, client);
if (handled) return;
if (handled) {return;}
// If not fully handled (e.g. /compact), fall through to send as message
}
_sending = true;
_elements.sendBtn.disabled = true;
if (!overrideText) input.value = '';
if (!overrideText) {input.value = '';}
// Apply search mode prefix
let messageText = rawText;
@@ -541,17 +541,17 @@ async function sendMessage(client, overrideText) {
placeholder.textContent = `Error: ${err.message}`;
} finally {
_sending = false;
if (_elements.sendBtn) _elements.sendBtn.disabled = false;
if (_elements.sendBtn) {_elements.sendBtn.disabled = false;}
scrollToBottom();
}
}
// ── Search SVG Icon ─────────────────────────────────────────
const SEARCH_ICON = `<svg viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path d="M8.5 3a5.5 5.5 0 0 1 4.38 8.82l4.15 4.15a.75.75 0 0 1-1.06 1.06l-4.15-4.15A5.5 5.5 0 1 1 8.5 3zm0 1.5a4 4 0 1 0 0 8 4 4 0 0 0 0-8z" fill="currentColor"/></svg>`;
const COPY_ICON = `<svg viewBox="0 0 16 16" xmlns="http://www.w3.org/2000/svg"><path d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 0 1 0 1.5h-1.5a.25.25 0 0 0-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 0 0 .25-.25v-1.5a.75.75 0 0 1 1.5 0v1.5A1.75 1.75 0 0 1 9.25 16h-7.5A1.75 1.75 0 0 1 0 14.25Z" fill="currentColor"/><path d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0 1 14.25 11h-7.5A1.75 1.75 0 0 1 5 9.25Zm1.75-.25a.25.25 0 0 0-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 0 0 .25-.25v-7.5a.25.25 0 0 0-.25-.25Z" fill="currentColor"/></svg>`;
const CHECK_ICON = `<svg viewBox="0 0 16 16" xmlns="http://www.w3.org/2000/svg"><path d="M13.78 4.22a.75.75 0 0 1 0 1.06l-7.25 7.25a.75.75 0 0 1-1.06 0L2.22 9.28a.75.75 0 0 1 1.06-1.06L6 10.94l6.72-6.72a.75.75 0 0 1 1.06 0Z" fill="currentColor"/></svg>`;
const EDIT_ICON = `<svg viewBox="0 0 16 16" xmlns="http://www.w3.org/2000/svg"><path d="M11.013 1.427a1.75 1.75 0 0 1 2.474 0l1.086 1.086a1.75 1.75 0 0 1 0 2.474l-8.61 8.61c-.21.21-.47.364-.756.445l-3.251.93a.75.75 0 0 1-.927-.928l.929-3.25c.081-.286.235-.547.445-.758l8.61-8.61Zm1.414 1.06a.25.25 0 0 0-.354 0L3.463 11.1l-.47 1.64 1.64-.47 8.61-8.61a.25.25 0 0 0 0-.354Z" fill="currentColor"/></svg>`;
const SEARCH_ICON = '<svg viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path d="M8.5 3a5.5 5.5 0 0 1 4.38 8.82l4.15 4.15a.75.75 0 0 1-1.06 1.06l-4.15-4.15A5.5 5.5 0 1 1 8.5 3zm0 1.5a4 4 0 1 0 0 8 4 4 0 0 0 0-8z" fill="currentColor"/></svg>';
const COPY_ICON = '<svg viewBox="0 0 16 16" xmlns="http://www.w3.org/2000/svg"><path d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 0 1 0 1.5h-1.5a.25.25 0 0 0-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 0 0 .25-.25v-1.5a.75.75 0 0 1 1.5 0v1.5A1.75 1.75 0 0 1 9.25 16h-7.5A1.75 1.75 0 0 1 0 14.25Z" fill="currentColor"/><path d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0 1 14.25 11h-7.5A1.75 1.75 0 0 1 5 9.25Zm1.75-.25a.25.25 0 0 0-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 0 0 .25-.25v-7.5a.25.25 0 0 0-.25-.25Z" fill="currentColor"/></svg>';
const CHECK_ICON = '<svg viewBox="0 0 16 16" xmlns="http://www.w3.org/2000/svg"><path d="M13.78 4.22a.75.75 0 0 1 0 1.06l-7.25 7.25a.75.75 0 0 1-1.06 0L2.22 9.28a.75.75 0 0 1 1.06-1.06L6 10.94l6.72-6.72a.75.75 0 0 1 1.06 0Z" fill="currentColor"/></svg>';
const EDIT_ICON = '<svg viewBox="0 0 16 16" xmlns="http://www.w3.org/2000/svg"><path d="M11.013 1.427a1.75 1.75 0 0 1 2.474 0l1.086 1.086a1.75 1.75 0 0 1 0 2.474l-8.61 8.61c-.21.21-.47.364-.756.445l-3.251.93a.75.75 0 0 1-.927-.928l.929-3.25c.081-.286.235-.547.445-.758l8.61-8.61Zm1.414 1.06a.25.25 0 0 0-.354 0L3.463 11.1l-.47 1.64 1.64-.47 8.61-8.61a.25.25 0 0 0 0-.354Z" fill="currentColor"/></svg>';
// ── Page Export ──────────────────────────────────────────────
+12 -12
View File
@@ -14,17 +14,17 @@ function formatUptime(seconds) {
const m = Math.floor((seconds % 3600) / 60);
const s = seconds % 60;
const parts = [];
if (d > 0) parts.push(`${d}d`);
if (h > 0) parts.push(`${h}h`);
if (m > 0) parts.push(`${m}m`);
if (d > 0) {parts.push(`${d}d`);}
if (h > 0) {parts.push(`${h}h`);}
if (m > 0) {parts.push(`${m}m`);}
parts.push(`${s}s`);
return parts.join(' ');
}
function timeAgo(timestamp) {
const secs = Math.floor((Date.now() - timestamp) / 1000);
if (secs < 60) return `${secs}s ago`;
if (secs < 3600) return `${Math.floor(secs / 60)}m ago`;
if (secs < 60) {return `${secs}s ago`;}
if (secs < 3600) {return `${Math.floor(secs / 60)}m ago`;}
return `${Math.floor(secs / 3600)}h ago`;
}
@@ -76,7 +76,7 @@ function renderSkeleton(el) {
function updateCounters(metrics, health) {
const el = document.getElementById('ops-counters');
if (!el) return;
if (!el) {return;}
const sessions = health?.sessions ?? 0;
const errCount = metrics?.errors ?? 0;
@@ -94,13 +94,13 @@ function updateCounters(metrics, health) {
`<div class="stat-card">
<div class="stat-label">${c.label}</div>
<div class="stat-value ${c.cls}">${c.value}</div>
</div>`
</div>`,
).join('');
}
function updateModelTable(metrics) {
const el = document.getElementById('ops-model-table');
if (!el) return;
if (!el) {return;}
const mc = metrics?.modelCalls;
const calls = mc?.recentCalls ?? [];
@@ -155,7 +155,7 @@ function updateModelTable(metrics) {
function updateEvents(eventsData) {
const el = document.getElementById('ops-events');
if (!el) return;
if (!el) {return;}
const events = eventsData?.events ?? [];
@@ -180,7 +180,7 @@ function updateEvents(eventsData) {
function updateActiveRequests(requestsData) {
const el = document.getElementById('ops-requests');
if (!el) return;
if (!el) {return;}
const requests = requestsData?.requests ?? [];
@@ -219,7 +219,7 @@ function updateActiveRequests(requestsData) {
function updateChannels(channelsData) {
const el = document.getElementById('ops-channels');
if (!el) return;
if (!el) {return;}
const channels = channelsData?.channels ?? [];
@@ -232,7 +232,7 @@ function updateChannels(channelsData) {
`<div class="channel-card">
<span class="channel-dot ${ch.status}"></span>
<span class="channel-name">${escapeHtml(ch.name)}</span>
</div>`
</div>`,
).join('');
}
+3 -3
View File
@@ -14,11 +14,11 @@ let _client = null;
let _el = null;
async function loadSessionList() {
if (!_client || !_el) return;
if (!_client || !_el) {return;}
const listContainer = _el.querySelector('#sessions-list');
const detailContainer = _el.querySelector('#session-detail');
if (detailContainer) detailContainer.innerHTML = '';
if (detailContainer) {detailContainer.innerHTML = '';}
try {
const result = await _client.call('sessions.list');
@@ -78,7 +78,7 @@ async function loadSessionList() {
async function viewSession(sessionId) {
const detailContainer = _el.querySelector('#session-detail');
if (!detailContainer) return;
if (!detailContainer) {return;}
detailContainer.innerHTML = '<div class="empty-state"><span class="spinner"></span> Loading...</div>';
+2 -2
View File
@@ -15,7 +15,7 @@ let _client = null;
let _el = null;
async function loadSettings() {
if (!_client || !_el) return;
if (!_client || !_el) {return;}
let config, tools, channels;
@@ -154,7 +154,7 @@ async function saveHooks() {
// Clear status after 5s
setTimeout(() => {
if (status) status.textContent = '';
if (status) {status.textContent = '';}
}, 5000);
}
+5 -5
View File
@@ -13,14 +13,14 @@ function formatNumber(n) {
}
function formatCost(n) {
if (!n || n === 0) return '$0.00';
if (n < 0.01) return `$${n.toFixed(4)}`;
if (!n || n === 0) {return '$0.00';}
if (n < 0.01) {return `$${n.toFixed(4)}`;}
return `$${n.toFixed(2)}`;
}
function truncateId(id) {
if (!id) return '-';
if (id.length <= 24) return id;
if (!id) {return '-';}
if (id.length <= 24) {return id;}
return id.slice(0, 24) + '\u2026';
}
@@ -95,7 +95,7 @@ async function loadUsage(el, client) {
let delegationCell = '<span class="text-muted">-</span>';
if (delegationEntries.length > 0) {
delegationCell = delegationEntries.map(([tier, stats]) =>
`<span class="badge ok">${tier}</span> ${formatNumber(stats.inputTokens)}/${formatNumber(stats.outputTokens)}`
`<span class="badge ok">${tier}</span> ${formatNumber(stats.inputTokens)}/${formatNumber(stats.outputTokens)}`,
).join('<br>');
}