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

View File

@@ -1,25 +1,22 @@
import type {
ReactNode} from 'react';
import React, { import React, {
type ReactNode,
createContext, createContext,
useContext, useContext,
useState, useState,
useEffect, useEffect,
useCallback useCallback,
} from 'react'; } from 'react';
import type { MantineColorScheme} from '@mantine/core'; import { useMantineColorScheme, type MantineColorScheme } from '@mantine/core';
import { useMantineColorScheme } from '@mantine/core';
import { notifications } from '@mantine/notifications'; import { notifications } from '@mantine/notifications';
import { DEFAULT_WORKSPACE_SETTINGS, type Workspace } from '@/types/models';
import { import {
deleteWorkspace,
getLastWorkspaceName, getLastWorkspaceName,
getWorkspace, getWorkspace,
updateWorkspace,
updateLastWorkspaceName,
deleteWorkspace,
listWorkspaces, listWorkspaces,
updateLastWorkspaceName,
updateWorkspace,
} from '@/api/workspace'; } from '@/api/workspace';
import type { Workspace} from '@/types/workspace';
import { DEFAULT_WORKSPACE_SETTINGS } from '@/types/workspace';
interface WorkspaceContextType { interface WorkspaceContextType {
currentWorkspace: Workspace | null; currentWorkspace: Workspace | null;
@@ -80,7 +77,7 @@ export const WorkspaceProvider: React.FC<WorkspaceProviderProps> = ({
}); });
} }
}, },
[] [setColorScheme]
); );
const loadFirstAvailableWorkspace = useCallback(async (): Promise<void> => { const loadFirstAvailableWorkspace = useCallback(async (): Promise<void> => {
@@ -100,7 +97,7 @@ export const WorkspaceProvider: React.FC<WorkspaceProviderProps> = ({
color: 'red', color: 'red',
}); });
} }
}, []); }, [loadWorkspaceData]);
useEffect(() => { useEffect(() => {
const initializeWorkspace = async (): Promise<void> => { const initializeWorkspace = async (): Promise<void> => {
@@ -120,8 +117,8 @@ export const WorkspaceProvider: React.FC<WorkspaceProviderProps> = ({
} }
}; };
initializeWorkspace(); void initializeWorkspace();
}, []); }, [loadFirstAvailableWorkspace, loadWorkspaceData, loadWorkspaces]);
const switchWorkspace = useCallback( const switchWorkspace = useCallback(
async (workspaceName: string): Promise<void> => { async (workspaceName: string): Promise<void> => {
@@ -141,7 +138,7 @@ export const WorkspaceProvider: React.FC<WorkspaceProviderProps> = ({
setLoading(false); setLoading(false);
} }
}, },
[] [loadWorkspaceData, loadWorkspaces]
); );
const deleteCurrentWorkspace = useCallback(async (): Promise<void> => { const deleteCurrentWorkspace = useCallback(async (): Promise<void> => {
@@ -182,7 +179,7 @@ export const WorkspaceProvider: React.FC<WorkspaceProviderProps> = ({
color: 'red', color: 'red',
}); });
} }
}, [currentWorkspace]); }, [currentWorkspace, loadWorkspaceData, loadWorkspaces]);
const updateSettings = useCallback( const updateSettings = useCallback(
async (newSettings: Partial<Workspace>): Promise<void> => { async (newSettings: Partial<Workspace>): Promise<void> => {
@@ -206,7 +203,7 @@ export const WorkspaceProvider: React.FC<WorkspaceProviderProps> = ({
throw error; throw error;
} }
}, },
[currentWorkspace, setColorScheme] [currentWorkspace, loadWorkspaces, setColorScheme]
); );
const updateColorScheme = useCallback( 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 { notifications } from '@mantine/notifications';
import { getUsers, getWorkspaces, getSystemStats } from '@/api/admin'; import { getUsers, getWorkspaces, getSystemStats } from '@/api/admin';
import type { SystemStats, WorkspaceStats } from '@/types/adminApi'; import type { SystemStats, User, WorkspaceStats } from '@/types/models';
import type { User } from '@/types/authApi';
// Possible types of admin data // Possible types of admin data
type AdminDataType = 'stats' | 'workspaces' | 'users'; type AdminDataType = 'stats' | 'workspaces' | 'users';
@@ -45,7 +44,7 @@ export const useAdminData = <T extends AdminDataType>(
const [loading, setLoading] = useState<boolean>(true); const [loading, setLoading] = useState<boolean>(true);
const [error, setError] = useState<string | null>(null); const [error, setError] = useState<string | null>(null);
const loadData = async () => { const loadData = useCallback(async () => {
setLoading(true); setLoading(true);
setError(null); setError(null);
try { try {
@@ -67,7 +66,8 @@ export const useAdminData = <T extends AdminDataType>(
} catch (err) { } catch (err) {
const message = const message =
err instanceof Error 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'; : 'An unknown error occurred';
setError(message); setError(message);
notifications.show({ notifications.show({
@@ -78,11 +78,11 @@ export const useAdminData = <T extends AdminDataType>(
} finally { } finally {
setLoading(false); setLoading(false);
} }
}; }, [type]);
useEffect(() => { useEffect(() => {
loadData(); void loadData();
}, [type]); }, [loadData]);
return { data, loading, error, reload: loadData }; return { data, loading, error, reload: loadData };
}; };

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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