infra: add linting and formatting for js projects (#230)

* wip

* wip

* wip

* format

* wip(mobile): lint and format

* cleanup

* nits

* nits

* idiomatic react

* nit

* format all root files
This commit was merged in pull request #230.
This commit is contained in:
Arjun Patel
2026-06-02 07:44:24 -07:00
committed by GitHub
parent 2fe562ce2b
commit a8a0b7db1b
258 changed files with 7822 additions and 5195 deletions
+21 -18
View File
@@ -1,5 +1,5 @@
import { z } from "zod";
import { appEnv } from "@/config/env";
import { z } from 'zod';
import { appEnv } from '@/config/env';
export class ApiError extends Error {
constructor(
@@ -7,7 +7,7 @@ export class ApiError extends Error {
message: string,
) {
super(message);
this.name = "ApiError";
this.name = 'ApiError';
}
}
@@ -18,44 +18,47 @@ export class ApiError extends Error {
*/
export class QuotaExceededError extends Error {
constructor(public readonly networkId: string) {
super("Daily message limit reached");
this.name = "QuotaExceededError";
super('Daily message limit reached');
this.name = 'QuotaExceededError';
}
}
const IPC_PREFIX = /^Error invoking remote method '[^']+':\s*/;
function normalizeMessage(message: string): string {
return message.replace(IPC_PREFIX, "").replace(/^Error:\s*/, "").trim();
return message
.replace(IPC_PREFIX, '')
.replace(/^Error:\s*/, '')
.trim();
}
export function toUserMessage(err: unknown): string {
if (err instanceof ApiError) {
if (err.status === 401) return "Please sign in again.";
if (err.status === 401) return 'Please sign in again.';
if (err.status === 403) return "You don't have permission to do that.";
if (err.status === 404) return "Not found.";
if (err.status === 404) return 'Not found.';
if (err.status === 408 || err.status === 429) {
return "Please try again in a moment.";
return 'Please try again in a moment.';
}
if (err.status >= 500) {
return "Something went wrong on our end. Please try again.";
return 'Something went wrong on our end. Please try again.';
}
return normalizeMessage(err.message) || "Request failed.";
return normalizeMessage(err.message) || 'Request failed.';
}
if (err instanceof z.ZodError) {
return "Received unexpected data from the server.";
return 'Received unexpected data from the server.';
}
if (err instanceof TypeError && /fetch|network/i.test(err.message)) {
return "Network error. Check your connection.";
return 'Network error. Check your connection.';
}
if (err instanceof Error) {
return normalizeMessage(err.message) || "Something went wrong.";
return normalizeMessage(err.message) || 'Something went wrong.';
}
return "Something went wrong.";
return 'Something went wrong.';
}
type ErrorContext = Record<string, unknown>;
@@ -77,9 +80,9 @@ export function installErrorSinks(sinks: {
/** Expected-but-recordable failures. Breadcrumb only — never pages anyone. */
export function logError(err: unknown, context?: ErrorContext): void {
if (appEnv === "dev") {
if (appEnv === 'dev') {
// eslint-disable-next-line no-console
console.error("[error]", err, context ?? {});
console.error('[error]', err, context ?? {});
}
breadcrumbSink?.(err, context);
}
@@ -87,6 +90,6 @@ export function logError(err: unknown, context?: ErrorContext): void {
/** Unexpected failures the user may not see. Always captured. */
export function reportError(err: unknown, context?: ErrorContext): void {
// eslint-disable-next-line no-console
console.error("[error]", err, context ?? {});
console.error('[error]', err, context ?? {});
captureSink?.(err, context);
}