Fix some lint issues

This commit is contained in:
2025-05-22 22:00:37 +02:00
parent 32218e5595
commit 646a897b93
12 changed files with 45 additions and 49 deletions

View File

@@ -12,7 +12,7 @@ import {
refreshToken as apiRefreshToken,
getCurrentUser,
} from '@/api/auth';
import type { User } from '@/types/authApi';
import type { User } from '@/types/models';
interface AuthContextType {
user: User | null;
@@ -49,7 +49,7 @@ export const AuthProvider: React.FC<AuthProviderProps> = ({ children }) => {
}
};
initializeAuth();
void initializeAuth();
}, []);
const login = useCallback(

View File

@@ -1,25 +1,22 @@
import type {
ReactNode} from 'react';
import React, {
type ReactNode,
createContext,
useContext,
useState,
useEffect,
useCallback
useCallback,
} from 'react';
import type { MantineColorScheme} from '@mantine/core';
import { useMantineColorScheme } from '@mantine/core';
import { useMantineColorScheme, type MantineColorScheme } from '@mantine/core';
import { notifications } from '@mantine/notifications';
import { DEFAULT_WORKSPACE_SETTINGS, type Workspace } from '@/types/models';
import {
deleteWorkspace,
getLastWorkspaceName,
getWorkspace,
updateWorkspace,
updateLastWorkspaceName,
deleteWorkspace,
listWorkspaces,
updateLastWorkspaceName,
updateWorkspace,
} from '@/api/workspace';
import type { Workspace} from '@/types/workspace';
import { DEFAULT_WORKSPACE_SETTINGS } from '@/types/workspace';
interface WorkspaceContextType {
currentWorkspace: Workspace | null;
@@ -80,7 +77,7 @@ export const WorkspaceProvider: React.FC<WorkspaceProviderProps> = ({
});
}
},
[]
[setColorScheme]
);
const loadFirstAvailableWorkspace = useCallback(async (): Promise<void> => {
@@ -100,7 +97,7 @@ export const WorkspaceProvider: React.FC<WorkspaceProviderProps> = ({
color: 'red',
});
}
}, []);
}, [loadWorkspaceData]);
useEffect(() => {
const initializeWorkspace = async (): Promise<void> => {
@@ -120,8 +117,8 @@ export const WorkspaceProvider: React.FC<WorkspaceProviderProps> = ({
}
};
initializeWorkspace();
}, []);
void initializeWorkspace();
}, [loadFirstAvailableWorkspace, loadWorkspaceData, loadWorkspaces]);
const switchWorkspace = useCallback(
async (workspaceName: string): Promise<void> => {
@@ -141,7 +138,7 @@ export const WorkspaceProvider: React.FC<WorkspaceProviderProps> = ({
setLoading(false);
}
},
[]
[loadWorkspaceData, loadWorkspaces]
);
const deleteCurrentWorkspace = useCallback(async (): Promise<void> => {
@@ -182,7 +179,7 @@ export const WorkspaceProvider: React.FC<WorkspaceProviderProps> = ({
color: 'red',
});
}
}, [currentWorkspace]);
}, [currentWorkspace, loadWorkspaceData, loadWorkspaces]);
const updateSettings = useCallback(
async (newSettings: Partial<Workspace>): Promise<void> => {
@@ -206,7 +203,7 @@ export const WorkspaceProvider: React.FC<WorkspaceProviderProps> = ({
throw error;
}
},
[currentWorkspace, setColorScheme]
[currentWorkspace, loadWorkspaces, setColorScheme]
);
const updateColorScheme = useCallback(

View File

@@ -1,8 +1,7 @@
import { useState, useEffect } from 'react';
import { useState, useEffect, useCallback } from 'react';
import { notifications } from '@mantine/notifications';
import { getUsers, getWorkspaces, getSystemStats } from '@/api/admin';
import type { SystemStats, WorkspaceStats } from '@/types/adminApi';
import type { User } from '@/types/authApi';
import type { SystemStats, User, WorkspaceStats } from '@/types/models';
// Possible types of admin data
type AdminDataType = 'stats' | 'workspaces' | 'users';
@@ -45,7 +44,7 @@ export const useAdminData = <T extends AdminDataType>(
const [loading, setLoading] = useState<boolean>(true);
const [error, setError] = useState<string | null>(null);
const loadData = async () => {
const loadData = useCallback(async () => {
setLoading(true);
setError(null);
try {
@@ -67,7 +66,8 @@ export const useAdminData = <T extends AdminDataType>(
} catch (err) {
const message =
err instanceof Error
? (err as any)?.response?.data?.error || err.message
? (err as { response?: { data?: { error?: string } } })?.response
?.data?.error || err.message
: 'An unknown error occurred';
setError(message);
notifications.show({
@@ -78,11 +78,11 @@ export const useAdminData = <T extends AdminDataType>(
} finally {
setLoading(false);
}
};
}, [type]);
useEffect(() => {
loadData();
}, [type]);
void loadData();
}, [loadData]);
return { data, loading, error, reload: loadData };
};

View File

@@ -1,8 +1,8 @@
import { useState, useCallback, useEffect } from 'react';
import { isImageFile } from '../utils/fileHelpers';
import { useWorkspace } from '../contexts/WorkspaceContext';
import { DEFAULT_FILE } from '@/types/file';
import { getFileContent } from '@/api/file';
import { DEFAULT_FILE } from '@/types/models';
interface UseFileContentResult {
content: string;
@@ -51,7 +51,7 @@ export const useFileContent = (
useEffect(() => {
if (selectedFile && currentWorkspace) {
loadFileContent(selectedFile);
void loadFileContent(selectedFile);
}
}, [selectedFile, currentWorkspace, loadFileContent]);

View File

@@ -1,7 +1,7 @@
import { useState, useCallback } from 'react';
import { listFiles } from '../api/file';
import { useWorkspace } from '../contexts/WorkspaceContext';
import type { FileNode } from '../types/fileApi';
import type { FileNode } from '@/types/models';
interface UseFileListResult {
files: FileNode[];

View File

@@ -1,7 +1,7 @@
import { useState, useCallback, useEffect } from 'react';
import { DEFAULT_FILE } from '../types/file';
import { useWorkspace } from '../contexts/WorkspaceContext';
import { useLastOpenedFile } from './useLastOpenedFile';
import { DEFAULT_FILE } from '@/types/models';
interface UseFileNavigationResult {
selectedFile: string;
@@ -36,14 +36,14 @@ export const useFileNavigation = (): UseFileNavigationResult => {
const lastFile = await loadLastOpenedFile();
if (lastFile) {
handleFileSelect(lastFile);
await handleFileSelect(lastFile);
} else {
handleFileSelect(null);
await handleFileSelect(null);
}
};
if (currentWorkspace) {
initializeFile();
void initializeFile();
}
}, [currentWorkspace, loadLastOpenedFile, handleFileSelect]);

View File

@@ -3,7 +3,7 @@ import { notifications } from '@mantine/notifications';
import { saveFile, deleteFile } from '../api/file';
import { useWorkspace } from '../contexts/WorkspaceContext';
import { useGitOperations } from './useGitOperations';
import { FileAction } from '../types/file';
import { FileAction } from '@/types/models';
interface UseFileOperationsResult {
handleSave: (filePath: string, content: string) => Promise<boolean>;
@@ -28,7 +28,7 @@ export const useFileOperations = (): UseFileOperationsResult => {
await handleCommitAndPush(commitMessage);
}
},
[settings]
[settings, handleCommitAndPush]
);
const handleSave = useCallback(

View File

@@ -2,7 +2,7 @@ import { useCallback } from 'react';
import { notifications } from '@mantine/notifications';
import { pullChanges, commitAndPush } from '../api/git';
import { useWorkspace } from '../contexts/WorkspaceContext';
import type { CommitHash } from '@/types/git';
import type { CommitHash } from '@/types/models';
interface UseGitOperationsResult {
handlePull: () => Promise<boolean>;

View File

@@ -1,8 +1,8 @@
import { useState, useCallback } from 'react';
import { notifications } from '@mantine/notifications';
import { updateProfile, deleteUser } from '../api/user';
import type { User } from '../types/authApi';
import type { UpdateProfileRequest } from '../types/userApi';
import type { UpdateProfileRequest } from '@/types/api';
import type { User } from '@/types/models';
interface UseProfileSettingsResult {
loading: boolean;

View File

@@ -5,8 +5,8 @@ import {
deleteUser as adminDeleteUser,
} from '../api/admin';
import { notifications } from '@mantine/notifications';
import type { User } from '../types/authApi';
import type { CreateUserRequest, UpdateUserRequest } from '../types/adminApi';
import type { User } from '@/types/models';
import type { CreateUserRequest, UpdateUserRequest } from '@/types/api';
interface UseUserAdminResult {
users: User[];
@@ -30,7 +30,7 @@ export const useUserAdmin = (): UseUserAdminResult => {
message: 'User created successfully',
color: 'green',
});
reload();
await reload();
return true;
} catch (err) {
const message = err instanceof Error ? err.message : String(err);
@@ -54,7 +54,7 @@ export const useUserAdmin = (): UseUserAdminResult => {
message: 'User updated successfully',
color: 'green',
});
reload();
await reload();
return true;
} catch (err) {
const message = err instanceof Error ? err.message : String(err);
@@ -75,7 +75,7 @@ export const useUserAdmin = (): UseUserAdminResult => {
message: 'User deleted successfully',
color: 'green',
});
reload();
await reload();
return true;
} catch (err) {
const message = err instanceof Error ? err.message : String(err);

View File

@@ -1,5 +1,5 @@
import { API_BASE_URL } from '@/types/authApi';
import { IMAGE_EXTENSIONS } from '../types/file';
import { API_BASE_URL } from '@/types/api';
import { IMAGE_EXTENSIONS } from '@/types/models';
/**
* Checks if the given file path has an image extension.

View File

@@ -1,10 +1,9 @@
import { visit } from 'unist-util-visit';
import { InlineContainerType, MARKDOWN_REGEX } from '../types/markdown';
import type { Node } from 'unist';
import type { Parent } from 'unist';
import type { Node, Parent } from 'unist';
import type { Text } from 'mdast';
import { lookupFileByName } from '@/api/file';
import { getFileUrl } from './fileHelpers';
import { InlineContainerType, MARKDOWN_REGEX } from '@/types/models';
/**
* Represents a wiki link match from the regex