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
+26 -25
View File
@@ -1,10 +1,13 @@
import { create } from "zustand";
import { signInWithCustomToken, signOut as firebaseSignOut } from "firebase/auth";
import { apiClient } from "@/api/client";
import type { Human } from "@/api/types";
import { firebaseAuth } from "@/firebase";
import { logError, ApiError } from "@/lib/errors";
import { useSessionStore } from "./session-store";
import { create } from 'zustand';
import {
signInWithCustomToken,
signOut as firebaseSignOut,
} from 'firebase/auth';
import { apiClient } from '@/api/client';
import type { Human } from '@/api/types';
import { firebaseAuth } from '@/firebase';
import { logError, ApiError } from '@/lib/errors';
import { useSessionStore } from './session-store';
async function signInToFirebase() {
try {
@@ -13,11 +16,11 @@ async function signInToFirebase() {
} catch (err) {
// Firestore subscriptions will fail until the next successful sign-in; the
// rest of the app keeps working against Orion.
logError(err, { scope: "auth.firebase" });
logError(err, { scope: 'auth.firebase' });
}
}
type AuthStatus = "idle" | "restoring" | "unauthenticated" | "authenticated";
type AuthStatus = 'idle' | 'restoring' | 'unauthenticated' | 'authenticated';
interface AuthState {
status: AuthStatus;
@@ -34,7 +37,7 @@ interface AuthState {
}
export const useAuthStore = create<AuthState>((set) => ({
status: "idle",
status: 'idle',
user: null,
isRequestingCode: false,
isSigningIn: false,
@@ -44,20 +47,20 @@ export const useAuthStore = create<AuthState>((set) => ({
restoreSession: async () => {
const token = useSessionStore.getState().token;
if (!token) {
set({ status: "unauthenticated" });
set({ status: 'unauthenticated' });
return;
}
set({ status: "restoring" });
set({ status: 'restoring' });
try {
const user = await apiClient.me();
await signInToFirebase();
set({ status: "authenticated", user });
set({ status: 'authenticated', user });
} catch (err) {
// Expected on expired/invalid tokens — fall back to the login screen.
logError(err, { scope: "auth.restore" });
logError(err, { scope: 'auth.restore' });
useSessionStore.getState().clearToken();
set({ status: "unauthenticated", user: null });
set({ status: 'unauthenticated', user: null });
}
},
@@ -66,8 +69,7 @@ export const useAuthStore = create<AuthState>((set) => ({
try {
await apiClient.requestCode({ email });
} catch (e) {
const message =
e instanceof ApiError ? e.message : "Failed to send code";
const message = e instanceof ApiError ? e.message : 'Failed to send code';
set({ error: message });
throw e;
} finally {
@@ -81,10 +83,9 @@ export const useAuthStore = create<AuthState>((set) => ({
const { human, token } = await apiClient.signIn({ email, code });
useSessionStore.getState().setToken(token);
await signInToFirebase();
set({ status: "authenticated", user: human });
set({ status: 'authenticated', user: human });
} catch (e) {
const message =
e instanceof ApiError ? e.message : "Failed to sign in";
const message = e instanceof ApiError ? e.message : 'Failed to sign in';
set({ error: message });
throw e;
} finally {
@@ -98,14 +99,14 @@ export const useAuthStore = create<AuthState>((set) => ({
await apiClient.signOut();
} catch (err) {
// Best-effort — sign out locally regardless.
logError(err, { scope: "auth.signOut" });
logError(err, { scope: 'auth.signOut' });
} finally {
await firebaseSignOut(firebaseAuth).catch((err) =>
logError(err, { scope: "auth.firebaseSignOut" }),
logError(err, { scope: 'auth.firebaseSignOut' }),
);
useSessionStore.getState().clearToken();
set({
status: "unauthenticated",
status: 'unauthenticated',
user: null,
isSigningOut: false,
error: null,
@@ -120,9 +121,9 @@ export const useAuthStore = create<AuthState>((set) => ({
useSessionStore.subscribe((state, prevState) => {
if (prevState.token && !state.token) {
const authState = useAuthStore.getState();
if (authState.status === "authenticated") {
if (authState.status === 'authenticated') {
useAuthStore.setState({
status: "unauthenticated",
status: 'unauthenticated',
user: null,
error: null,
});