mirror of
https://github.com/kjanat/livedash-node.git
synced 2026-01-16 19:32:08 +01:00
refactor: achieve 100% biome compliance with comprehensive code quality improvements
- Fix all cognitive complexity violations (63→0 errors) - Replace 'any' types with proper TypeScript interfaces and generics - Extract helper functions and custom hooks to reduce complexity - Fix React hook dependency arrays and useCallback patterns - Remove unused imports, variables, and functions - Implement proper formatting across all files - Add type safety with interfaces like AIProcessingRequestWithSession - Fix circuit breaker implementation with proper reset() method - Resolve all accessibility and form labeling issues - Clean up mysterious './0' file containing biome output Total: 63 errors → 0 errors, 42 warnings → 0 warnings
This commit is contained in:
@ -98,15 +98,16 @@ export function useCSRFFetch() {
|
||||
async (url: string, options: RequestInit = {}): Promise<Response> => {
|
||||
// Ensure we have a token for state-changing requests
|
||||
const method = options.method || "GET";
|
||||
let modifiedOptions = options;
|
||||
if (["POST", "PUT", "DELETE", "PATCH"].includes(method.toUpperCase())) {
|
||||
const currentToken = token || (await getToken());
|
||||
if (currentToken) {
|
||||
options = CSRFClient.addTokenToFetch(options);
|
||||
modifiedOptions = CSRFClient.addTokenToFetch(options);
|
||||
}
|
||||
}
|
||||
|
||||
return fetch(url, {
|
||||
...options,
|
||||
...modifiedOptions,
|
||||
credentials: "include", // Ensure cookies are sent
|
||||
});
|
||||
},
|
||||
@ -164,8 +165,9 @@ export function useCSRFForm() {
|
||||
): Promise<Response> => {
|
||||
// Ensure we have a token
|
||||
const currentToken = token || (await getToken());
|
||||
let modifiedData = data;
|
||||
if (currentToken) {
|
||||
data = CSRFClient.addTokenToObject(data);
|
||||
modifiedData = CSRFClient.addTokenToObject(data);
|
||||
}
|
||||
|
||||
return fetch(url, {
|
||||
@ -174,7 +176,7 @@ export function useCSRFForm() {
|
||||
"Content-Type": "application/json",
|
||||
...options.headers,
|
||||
},
|
||||
body: JSON.stringify(data),
|
||||
body: JSON.stringify(modifiedData),
|
||||
credentials: "include",
|
||||
...options,
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user