style(app): apply eslint --fix to Tier 2 (TypeScript plumbing)

WS-3 session 1b-i Tier 2.

Scope: composables, lib, stores, plugins, types, utils, navigation,
main.ts. Mechanical fixes only — predominantly newline-before-return,
arrow-parens, antfu/if-newline, padding-line-between-statements, plus
one unicorn/prefer-includes (.some(p => x === p) → .includes(x))
in router guards.

Excludes (per session prompt):
- apps/app/vite.config.ts (Tier 3)
- apps/app/themeConfig.ts (Tier 3)
- apps/app/vitest.config.ts (Tier 3)
- All .vue files (already in Tier 1)

Hand-reviewed diffs for the three auth/router-critical files before
committing:
- src/lib/axios.ts: reviewed clean. Pure mechanical (quote-props on
  Accept header, curly-strip on single-statement ifs, one blank line
  before impersonationStore.clearState()). No type-import changes,
  no logic touched.
- src/stores/useAuthStore.ts: reviewed clean. curly-strip + padding
  before returns. The initialize()/doInitialize() race-condition guard
  on isInitialized is preserved verbatim.
- src/plugins/1.router/guards.ts: reviewed clean. if-newline reformat
  + one .some() → .includes() rewrite that's behaviorally identical
  for primitive equality on the guestOnlyPaths string array.

Tests + typecheck verified green post-fix:
- apps/app vitest: 49 passed (unchanged)
- apps/app vue-tsc: clean (unchanged)

Lint baseline progression:
- Pre-Tier-2: 422 problems (post-Tier-1)
- Post-Tier-2: 246 problems

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
2026-04-29 11:06:46 +02:00
parent 47bd533179
commit a7eaf0f948
28 changed files with 189 additions and 97 deletions

View File

@@ -18,6 +18,7 @@ export const useAuthStore = defineStore('auth', () => {
const currentOrganisation = computed(() => {
const orgStore = useOrganisationStore()
return organisations.value.find(o => o.id === orgStore.activeOrganisationId)
?? organisations.value[0]
?? null
@@ -43,13 +44,13 @@ export const useAuthStore = defineStore('auth', () => {
// Auto-select first organisation if none is active
const orgStore = useOrganisationStore()
if (!orgStore.activeOrganisationId && me.organisations.length > 0) {
if (!orgStore.activeOrganisationId && me.organisations.length > 0)
orgStore.setActiveOrganisation(me.organisations[0].id)
}
}
function setActiveOrganisation(id: string) {
const orgStore = useOrganisationStore()
orgStore.setActiveOrganisation(id)
}
@@ -61,19 +62,20 @@ export const useAuthStore = defineStore('auth', () => {
mfaSetupRequired.value = false
const orgStore = useOrganisationStore()
orgStore.clear()
}
function handleUnauthorized() {
clearState()
// Do NOT reset isInitialized — the full page reload (below) resets all JS state.
// Resetting it here causes a race condition: the async 401 interceptor fires
// after doInitialize() sets isInitialized=true, putting the app back into
// a loading state that never resolves.
if (typeof window !== 'undefined' && window.location.pathname !== '/login') {
if (typeof window !== 'undefined' && window.location.pathname !== '/login')
window.location.href = '/login'
}
}
async function logout() {
@@ -95,6 +97,7 @@ export const useAuthStore = defineStore('auth', () => {
async function refreshUser(): Promise<void> {
try {
const { data } = await apiClient.get<{ success: boolean; data: MeResponse }>('/auth/me')
setUser(data.data)
}
catch {
@@ -110,16 +113,18 @@ export const useAuthStore = defineStore('auth', () => {
let initializePromise: Promise<void> | null = null
function initialize(): Promise<void> {
if (isInitialized.value) return Promise.resolve()
if (!initializePromise) {
if (isInitialized.value)
return Promise.resolve()
if (!initializePromise)
initializePromise = doInitialize()
}
return initializePromise
}
async function doInitialize(): Promise<void> {
try {
const { data } = await apiClient.get<{ success: boolean; data: MeResponse }>('/auth/me')
setUser(data.data)
}
catch {

View File

@@ -1,7 +1,7 @@
import { defineStore } from 'pinia'
import { computed, ref } from 'vue'
import { apiClient } from '@/lib/axios'
import type { AdminUser, ImpersonationSession, ImpersonationStartResponse, ImpersonationStatusResponse, StartImpersonationPayload } from '@/types/admin'
import type { AdminUser, ImpersonationStartResponse, ImpersonationStatusResponse, StartImpersonationPayload } from '@/types/admin'
const SESSION_STORAGE_KEY = 'crewli_impersonation'
const BROADCAST_CHANNEL_NAME = 'crewli_impersonation_sync'
@@ -27,12 +27,11 @@ export const useImpersonationStore = defineStore('impersonation', () => {
const expiresAt = computed(() => state.value?.expiresAt ? new Date(state.value.expiresAt) : null)
function persistState(): void {
if (state.value) {
if (state.value)
sessionStorage.setItem(SESSION_STORAGE_KEY, JSON.stringify(state.value))
}
else {
else
sessionStorage.removeItem(SESSION_STORAGE_KEY)
}
}
async function start(
@@ -69,12 +68,12 @@ export const useImpersonationStore = defineStore('impersonation', () => {
// Call stop WITHOUT the X-Impersonate-User header
// The interceptor won't add it because we clear state first
const currentState = state.value
state.value = null
persistState()
if (currentState) {
if (currentState)
await apiClient.post('/admin/stop-impersonation')
}
}
catch {
// Even if API call fails, state is already cleared
@@ -130,7 +129,8 @@ export const useImpersonationStore = defineStore('impersonation', () => {
}
function listenForBroadcasts(): void {
if (broadcastChannel) return
if (broadcastChannel)
return
try {
broadcastChannel = new BroadcastChannel(BROADCAST_CHANNEL_NAME)

View File

@@ -25,7 +25,8 @@ export const useShiftDetailStore = defineStore('shiftDetail', () => {
function toggleAssignmentSelection(id: string) {
const idx = selectedAssignmentIds.value.indexOf(id)
if (idx === -1) selectedAssignmentIds.value.push(id)
if (idx === -1)
selectedAssignmentIds.value.push(id)
else selectedAssignmentIds.value.splice(idx, 1)
}