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:
@@ -13,7 +13,7 @@ export class ManagedSession implements Session {
|
||||
constructor(
|
||||
public readonly id: string,
|
||||
private store: SessionStore,
|
||||
private history: Message[] = []
|
||||
private history: Message[] = [],
|
||||
) {}
|
||||
|
||||
addMessage(message: Message): Message {
|
||||
@@ -76,7 +76,7 @@ export class SessionManager {
|
||||
fromFrontend: string,
|
||||
fromUserId: string,
|
||||
toFrontend: string,
|
||||
toUserId: string
|
||||
toUserId: string,
|
||||
): void {
|
||||
const fromSession = this.getSession(fromFrontend, fromUserId);
|
||||
const toSession = this.getSession(toFrontend, toUserId);
|
||||
|
||||
@@ -4,9 +4,9 @@ import type { PairingStore, ApprovedSender } from '../channels/pairing.js';
|
||||
|
||||
/** Parse a duration string like '30d', '7d', '12h' to milliseconds. Returns null if invalid or '0'. */
|
||||
export function parseDuration(s: string): number | null {
|
||||
if (s === '0' || s === 'false') return null;
|
||||
if (s === '0' || s === 'false') {return null;}
|
||||
const match = s.match(/^(\d+)(h|d)$/);
|
||||
if (!match) return null;
|
||||
if (!match) {return null;}
|
||||
const [, n, unit] = match;
|
||||
return unit === 'h' ? Number(n) * 3600_000 : Number(n) * 86_400_000;
|
||||
}
|
||||
@@ -41,14 +41,14 @@ export class SessionStore {
|
||||
|
||||
addMessage(sessionId: string, message: Message): void {
|
||||
const stmt = this.db.prepare(
|
||||
'INSERT INTO messages (session_id, role, content) VALUES (?, ?, ?)'
|
||||
'INSERT INTO messages (session_id, role, content) VALUES (?, ?, ?)',
|
||||
);
|
||||
stmt.run(sessionId, message.role, message.content);
|
||||
}
|
||||
|
||||
getMessages(sessionId: string): Message[] {
|
||||
const stmt = this.db.prepare(
|
||||
'SELECT role, content FROM messages WHERE session_id = ? ORDER BY id ASC'
|
||||
'SELECT role, content FROM messages WHERE session_id = ? ORDER BY id ASC',
|
||||
);
|
||||
const rows = stmt.all(sessionId) as Array<{ role: string; content: string }>;
|
||||
return rows.map(row => ({
|
||||
@@ -68,7 +68,7 @@ export class SessionStore {
|
||||
this.db.prepare('DELETE FROM messages WHERE session_id = ?').run(sessionId);
|
||||
// Re-insert in order
|
||||
const insert = this.db.prepare(
|
||||
'INSERT INTO messages (session_id, role, content) VALUES (?, ?, ?)'
|
||||
'INSERT INTO messages (session_id, role, content) VALUES (?, ?, ?)',
|
||||
);
|
||||
for (const msg of messages) {
|
||||
insert.run(sessionId, msg.role, msg.content);
|
||||
@@ -96,7 +96,7 @@ export class SessionStore {
|
||||
HAVING MAX(created_at) < ?
|
||||
`).all(beforeTimestamp) as Array<{ session_id: string }>;
|
||||
|
||||
if (stale.length === 0) return [];
|
||||
if (stale.length === 0) {return [];}
|
||||
|
||||
const deleteStmt = this.db.prepare('DELETE FROM messages WHERE session_id = ?');
|
||||
const transaction = this.db.transaction(() => {
|
||||
@@ -113,7 +113,7 @@ export class SessionStore {
|
||||
return {
|
||||
loadApproved: (): ApprovedSender[] => {
|
||||
const rows = this.db.prepare(
|
||||
'SELECT channel, sender_id, approved_at, code_used FROM pairing_approved'
|
||||
'SELECT channel, sender_id, approved_at, code_used FROM pairing_approved',
|
||||
).all() as Array<{ channel: string; sender_id: string; approved_at: number; code_used: string }>;
|
||||
return rows.map(r => ({
|
||||
channel: r.channel,
|
||||
@@ -130,7 +130,7 @@ export class SessionStore {
|
||||
},
|
||||
removeApproved: (channel: string, senderId: string): void => {
|
||||
this.db.prepare(
|
||||
'DELETE FROM pairing_approved WHERE channel = ? AND sender_id = ?'
|
||||
'DELETE FROM pairing_approved WHERE channel = ? AND sender_id = ?',
|
||||
).run(channel, senderId);
|
||||
},
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user