mirror of
https://github.com/lordmathis/lemma.git
synced 2025-11-05 15:44:21 +00:00
Run npm lint:fix
This commit is contained in:
@@ -1,12 +1,15 @@
|
||||
import { apiCall } from './api';
|
||||
import { API_BASE_URL, isUser, User } from '../types/authApi';
|
||||
import {
|
||||
import type { User } from '../types/authApi';
|
||||
import { API_BASE_URL, isUser } from '../types/authApi';
|
||||
import type {
|
||||
CreateUserRequest,
|
||||
isSystemStats,
|
||||
SystemStats,
|
||||
UpdateUserRequest,
|
||||
UpdateUserRequest} from '@/types/adminApi';
|
||||
import {
|
||||
isSystemStats
|
||||
} from '@/types/adminApi';
|
||||
import { isWorkspace, Workspace } from '@/types/workspace';
|
||||
import type { Workspace } from '@/types/workspace';
|
||||
import { isWorkspace } from '@/types/workspace';
|
||||
|
||||
const ADMIN_BASE_URL = `${API_BASE_URL}/admin`;
|
||||
|
||||
@@ -28,7 +31,7 @@ export const getUsers = async (): Promise<User[]> => {
|
||||
if (!isUser(user)) {
|
||||
throw new Error('Invalid user object received from API');
|
||||
}
|
||||
return user as User;
|
||||
return user;
|
||||
});
|
||||
};
|
||||
|
||||
@@ -50,7 +53,7 @@ export const createUser = async (
|
||||
if (!isUser(data)) {
|
||||
throw new Error('Invalid user object received from API');
|
||||
}
|
||||
return data as User;
|
||||
return data;
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -89,7 +92,7 @@ export const updateUser = async (
|
||||
if (!isUser(data)) {
|
||||
throw new Error('Invalid user object received from API');
|
||||
}
|
||||
return data as User;
|
||||
return data;
|
||||
};
|
||||
|
||||
// Workspace Management
|
||||
@@ -109,7 +112,7 @@ export const getWorkspaces = async (): Promise<Workspace[]> => {
|
||||
if (!isWorkspace(workspace)) {
|
||||
throw new Error('Invalid workspace object received from API');
|
||||
}
|
||||
return workspace as Workspace;
|
||||
return workspace;
|
||||
});
|
||||
};
|
||||
|
||||
@@ -126,5 +129,5 @@ export const getSystemStats = async (): Promise<SystemStats> => {
|
||||
if (!isSystemStats(data)) {
|
||||
throw new Error('Invalid system stats response received from API');
|
||||
}
|
||||
return data as SystemStats;
|
||||
return data;
|
||||
};
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { API_BASE_URL, User, LoginRequest, isUser } from '../types/authApi';
|
||||
import type { User, LoginRequest} from '../types/authApi';
|
||||
import { API_BASE_URL, isUser } from '../types/authApi';
|
||||
import { apiCall } from './api';
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,12 +1,13 @@
|
||||
import { API_BASE_URL } from '@/types/authApi';
|
||||
import { apiCall } from './api';
|
||||
import {
|
||||
import type {
|
||||
FileNode,
|
||||
LookupResponse,
|
||||
SaveFileResponse} from '@/types/fileApi';
|
||||
import {
|
||||
isFileNode,
|
||||
isLookupResponse,
|
||||
isSaveFileResponse,
|
||||
LookupResponse,
|
||||
SaveFileResponse,
|
||||
isSaveFileResponse
|
||||
} from '@/types/fileApi';
|
||||
|
||||
/**
|
||||
@@ -27,7 +28,7 @@ export const listFiles = async (workspaceName: string): Promise<FileNode[]> => {
|
||||
if (!isFileNode(file)) {
|
||||
throw new Error('Invalid file object received from API');
|
||||
}
|
||||
return file as FileNode;
|
||||
return file;
|
||||
});
|
||||
};
|
||||
|
||||
@@ -51,7 +52,7 @@ export const lookupFileByName = async (
|
||||
if (!isLookupResponse(data)) {
|
||||
throw new Error('Invalid lookup response received from API');
|
||||
}
|
||||
const lookupResponse = data as LookupResponse;
|
||||
const lookupResponse = data;
|
||||
return lookupResponse.paths;
|
||||
};
|
||||
|
||||
@@ -103,7 +104,7 @@ export const saveFile = async (
|
||||
if (!isSaveFileResponse(data)) {
|
||||
throw new Error('Invalid save file response received from API');
|
||||
}
|
||||
return data as SaveFileResponse;
|
||||
return data;
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { API_BASE_URL } from '@/types/authApi';
|
||||
import { apiCall } from './api';
|
||||
import { CommitHash } from '@/types/git';
|
||||
import type { CommitHash } from '@/types/git';
|
||||
|
||||
/**
|
||||
* pullChanges fetches the latest changes from the remote repository
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import { API_BASE_URL, isUser, User } from '@/types/authApi';
|
||||
import type { User } from '@/types/authApi';
|
||||
import { API_BASE_URL, isUser } from '@/types/authApi';
|
||||
import { apiCall } from './api';
|
||||
import { UpdateProfileRequest } from '@/types/userApi';
|
||||
import type { UpdateProfileRequest } from '@/types/userApi';
|
||||
|
||||
/**
|
||||
* updateProfile updates the user's profile information.
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import { API_BASE_URL } from '@/types/authApi';
|
||||
import { apiCall } from './api';
|
||||
import { isWorkspace, Workspace } from '@/types/workspace';
|
||||
import type { Workspace } from '@/types/workspace';
|
||||
import { isWorkspace } from '@/types/workspace';
|
||||
|
||||
/**
|
||||
* listWorkspaces fetches the list of workspaces
|
||||
@@ -17,7 +18,7 @@ export const listWorkspaces = async (): Promise<Workspace[]> => {
|
||||
if (!isWorkspace(workspace)) {
|
||||
throw new Error('Invalid workspace object received from API');
|
||||
}
|
||||
return workspace as Workspace;
|
||||
return workspace;
|
||||
});
|
||||
};
|
||||
|
||||
@@ -39,7 +40,7 @@ export const createWorkspace = async (name: string): Promise<Workspace> => {
|
||||
if (!isWorkspace(data)) {
|
||||
throw new Error('Invalid workspace object received from API');
|
||||
}
|
||||
return data as Workspace;
|
||||
return data;
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import React, { FormEvent, useState } from 'react';
|
||||
import type { FormEvent} from 'react';
|
||||
import React, { useState } from 'react';
|
||||
import {
|
||||
TextInput,
|
||||
PasswordInput,
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import React, { useState, useEffect, useMemo, ReactNode } from 'react';
|
||||
import type { ReactNode } from 'react';
|
||||
import React, { useState, useEffect, useMemo } from 'react';
|
||||
import { unified } from 'unified';
|
||||
import remarkParse from 'remark-parse';
|
||||
import remarkMath from 'remark-math';
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
import React, { useRef, useState, useLayoutEffect } from 'react';
|
||||
import { Tree, NodeApi } from 'react-arborist';
|
||||
import type { NodeApi } from 'react-arborist';
|
||||
import { Tree } from 'react-arborist';
|
||||
import { IconFile, IconFolder, IconFolderOpen } from '@tabler/icons-react';
|
||||
import { Tooltip } from '@mantine/core';
|
||||
import useResizeObserver from '@react-hook/resize-observer';
|
||||
import { FileNode } from '../../types/fileApi';
|
||||
import type { FileNode } from '../../types/fileApi';
|
||||
|
||||
interface Size {
|
||||
width: number;
|
||||
@@ -48,7 +49,7 @@ function Node(props: any) {
|
||||
if (node.isInternal) {
|
||||
node.toggle();
|
||||
} else {
|
||||
const treeProps = node.tree.props as any;
|
||||
const treeProps = node.tree.props;
|
||||
if (typeof treeProps.onNodeClick === 'function') {
|
||||
treeProps.onNodeClick(node);
|
||||
}
|
||||
@@ -124,7 +125,7 @@ const FileTree: React.FC<FileTreeProps> = ({
|
||||
{...({
|
||||
// Use a spread with type assertion to add onNodeClick
|
||||
onNodeClick: (node: NodeApi<FileNode>) => {
|
||||
const fileNode = node.data as FileNode;
|
||||
const fileNode = node.data;
|
||||
if (!node.isInternal) {
|
||||
handleFileSelect(fileNode.path);
|
||||
}
|
||||
|
||||
@@ -42,7 +42,7 @@ const MainContent: React.FC<MainContentProps> = ({
|
||||
|
||||
const handleSaveFile = useCallback(
|
||||
async (filePath: string, fileContent: string): Promise<boolean> => {
|
||||
let success = await handleSave(filePath, fileContent);
|
||||
const success = await handleSave(filePath, fileContent);
|
||||
if (success) {
|
||||
setHasUnsavedChanges(false);
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@ import FileActions from '../files/FileActions';
|
||||
import FileTree from '../files/FileTree';
|
||||
import { useGitOperations } from '../../hooks/useGitOperations';
|
||||
import { useWorkspace } from '../../contexts/WorkspaceContext';
|
||||
import { FileNode } from '@/types/fileApi';
|
||||
import type { FileNode } from '@/types/fileApi';
|
||||
|
||||
interface SidebarProps {
|
||||
selectedFile: string | null;
|
||||
|
||||
@@ -8,7 +8,7 @@ import {
|
||||
Button,
|
||||
Group,
|
||||
} from '@mantine/core';
|
||||
import { CreateUserRequest } from '@/types/adminApi';
|
||||
import type { CreateUserRequest } from '@/types/adminApi';
|
||||
import { UserRole } from '@/types/authApi';
|
||||
|
||||
interface CreateUserModalProps {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import React from 'react';
|
||||
import { Modal, Text, Button, Group, Stack } from '@mantine/core';
|
||||
import { User } from '@/types/authApi';
|
||||
import type { User } from '@/types/authApi';
|
||||
|
||||
interface DeleteUserModalProps {
|
||||
opened: boolean;
|
||||
|
||||
@@ -9,8 +9,9 @@ import {
|
||||
PasswordInput,
|
||||
Text,
|
||||
} from '@mantine/core';
|
||||
import { UpdateUserRequest } from '@/types/adminApi';
|
||||
import { User, UserRole } from '@/types/authApi';
|
||||
import type { UpdateUserRequest } from '@/types/adminApi';
|
||||
import type { User} from '@/types/authApi';
|
||||
import { UserRole } from '@/types/authApi';
|
||||
|
||||
interface EditUserModalProps {
|
||||
opened: boolean;
|
||||
|
||||
@@ -2,7 +2,7 @@ import React, { useState } from 'react';
|
||||
import { Modal, TextInput, Button, Group, Box } from '@mantine/core';
|
||||
import { useModalContext } from '../../../contexts/ModalContext';
|
||||
import { notifications } from '@mantine/notifications';
|
||||
import { Workspace } from '@/types/workspace';
|
||||
import type { Workspace } from '@/types/workspace';
|
||||
import { createWorkspace } from '@/api/workspace';
|
||||
|
||||
interface CreateWorkspaceModalProps {
|
||||
|
||||
@@ -19,7 +19,7 @@ import { useWorkspace } from '../../contexts/WorkspaceContext';
|
||||
import { useModalContext } from '../../contexts/ModalContext';
|
||||
import { listWorkspaces } from '../../api/workspace';
|
||||
import CreateWorkspaceModal from '../modals/workspace/CreateWorkspaceModal';
|
||||
import { Workspace } from '../../types/workspace';
|
||||
import type { Workspace } from '../../types/workspace';
|
||||
|
||||
const WorkspaceSwitcher: React.FC = () => {
|
||||
const { currentWorkspace, switchWorkspace } = useWorkspace();
|
||||
|
||||
@@ -16,11 +16,12 @@ import SecuritySettings from './SecuritySettings';
|
||||
import ProfileSettings from './ProfileSettings';
|
||||
import DangerZoneSettings from './DangerZoneSettings';
|
||||
import AccordionControl from '../AccordionControl';
|
||||
import {
|
||||
SettingsActionType,
|
||||
import type {
|
||||
UserProfileSettings,
|
||||
ProfileSettingsState,
|
||||
SettingsAction,
|
||||
SettingsAction} from '../../../types/settings';
|
||||
import {
|
||||
SettingsActionType
|
||||
} from '../../../types/settings';
|
||||
|
||||
interface AccountSettingsProps {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import React from 'react';
|
||||
import { Box, Stack, TextInput } from '@mantine/core';
|
||||
import { UserProfileSettings } from '../../../types/settings';
|
||||
import type { UserProfileSettings } from '../../../types/settings';
|
||||
|
||||
interface ProfileSettingsProps {
|
||||
settings: UserProfileSettings;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import React, { useState } from 'react';
|
||||
import { Box, PasswordInput, Stack, Text } from '@mantine/core';
|
||||
import { UserProfileSettings } from '@/types/settings';
|
||||
import type { UserProfileSettings } from '@/types/settings';
|
||||
|
||||
interface SecuritySettingsProps {
|
||||
settings: UserProfileSettings;
|
||||
|
||||
@@ -20,8 +20,8 @@ import { useUserAdmin } from '../../../hooks/useUserAdmin';
|
||||
import CreateUserModal from '../../modals/user/CreateUserModal';
|
||||
import EditUserModal from '../../modals/user/EditUserModal';
|
||||
import DeleteUserModal from '../../modals/user/DeleteUserModal';
|
||||
import { User } from '../../../types/authApi';
|
||||
import { CreateUserRequest, UpdateUserRequest } from '../../../types/adminApi';
|
||||
import type { User } from '../../../types/authApi';
|
||||
import type { CreateUserRequest, UpdateUserRequest } from '../../../types/adminApi';
|
||||
|
||||
interface AdminUsersTabProps {
|
||||
currentUser: User;
|
||||
|
||||
@@ -3,7 +3,7 @@ import { Table, Group, Text, Box, LoadingOverlay, Alert } from '@mantine/core';
|
||||
import { IconAlertCircle } from '@tabler/icons-react';
|
||||
import { useAdminData } from '../../../hooks/useAdminData';
|
||||
import { formatBytes } from '../../../utils/formatBytes';
|
||||
import { FileCountStats, WorkspaceStats } from '../../../types/adminApi';
|
||||
import type { FileCountStats, WorkspaceStats } from '../../../types/adminApi';
|
||||
|
||||
const AdminWorkspacesTab: React.FC = () => {
|
||||
const {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import React from 'react';
|
||||
import { Box, TextInput, Text, Grid } from '@mantine/core';
|
||||
import { Workspace } from '@/types/workspace';
|
||||
import type { Workspace } from '@/types/workspace';
|
||||
|
||||
interface GeneralSettingsProps {
|
||||
name: string;
|
||||
|
||||
@@ -8,7 +8,7 @@ import {
|
||||
Group,
|
||||
Grid,
|
||||
} from '@mantine/core';
|
||||
import { Workspace } from '@/types/workspace';
|
||||
import type { Workspace } from '@/types/workspace';
|
||||
|
||||
interface GitSettingsProps {
|
||||
gitEnabled: boolean;
|
||||
|
||||
@@ -17,8 +17,9 @@ import GeneralSettings from './GeneralSettings';
|
||||
import { useModalContext } from '../../../contexts/ModalContext';
|
||||
import DangerZoneSettings from './DangerZoneSettings';
|
||||
import AccordionControl from '../AccordionControl';
|
||||
import { SettingsActionType, SettingsAction } from '../../../types/settings';
|
||||
import { Workspace } from '../../../types/workspace';
|
||||
import type { SettingsAction } from '../../../types/settings';
|
||||
import { SettingsActionType } from '../../../types/settings';
|
||||
import type { Workspace } from '../../../types/workspace';
|
||||
|
||||
// State and reducer for workspace settings
|
||||
interface WorkspaceSettingsState {
|
||||
|
||||
@@ -12,7 +12,7 @@ import {
|
||||
refreshToken as apiRefreshToken,
|
||||
getCurrentUser,
|
||||
} from '@/api/auth';
|
||||
import { User } from '@/types/authApi';
|
||||
import type { User } from '@/types/authApi';
|
||||
|
||||
interface AuthContextType {
|
||||
user: User | null;
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import React, { createContext, useContext, useState, ReactNode } from 'react';
|
||||
import type { ReactNode } from 'react';
|
||||
import React, { createContext, useContext, useState } from 'react';
|
||||
|
||||
interface ModalContextType {
|
||||
newFileModalVisible: boolean;
|
||||
|
||||
@@ -1,12 +1,14 @@
|
||||
import type {
|
||||
ReactNode} from 'react';
|
||||
import React, {
|
||||
createContext,
|
||||
useContext,
|
||||
useState,
|
||||
useEffect,
|
||||
useCallback,
|
||||
ReactNode,
|
||||
useCallback
|
||||
} from 'react';
|
||||
import { MantineColorScheme, useMantineColorScheme } from '@mantine/core';
|
||||
import type { MantineColorScheme} from '@mantine/core';
|
||||
import { useMantineColorScheme } from '@mantine/core';
|
||||
import { notifications } from '@mantine/notifications';
|
||||
import {
|
||||
getLastWorkspaceName,
|
||||
@@ -16,7 +18,8 @@ import {
|
||||
deleteWorkspace,
|
||||
listWorkspaces,
|
||||
} from '@/api/workspace';
|
||||
import { Workspace, DEFAULT_WORKSPACE_SETTINGS } from '@/types/workspace';
|
||||
import type { Workspace} from '@/types/workspace';
|
||||
import { DEFAULT_WORKSPACE_SETTINGS } from '@/types/workspace';
|
||||
|
||||
interface WorkspaceContextType {
|
||||
currentWorkspace: Workspace | null;
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import { useState, useEffect } from 'react';
|
||||
import { notifications } from '@mantine/notifications';
|
||||
import { getUsers, getWorkspaces, getSystemStats } from '@/api/admin';
|
||||
import { SystemStats, WorkspaceStats } from '@/types/adminApi';
|
||||
import { User } from '@/types/authApi';
|
||||
import type { SystemStats, WorkspaceStats } from '@/types/adminApi';
|
||||
import type { User } from '@/types/authApi';
|
||||
|
||||
// Possible types of admin data
|
||||
type AdminDataType = 'stats' | 'workspaces' | 'users';
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { useState, useCallback } from 'react';
|
||||
import { listFiles } from '../api/file';
|
||||
import { useWorkspace } from '../contexts/WorkspaceContext';
|
||||
import { FileNode } from '../types/fileApi';
|
||||
import type { FileNode } from '../types/fileApi';
|
||||
|
||||
interface UseFileListResult {
|
||||
files: FileNode[];
|
||||
|
||||
@@ -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 { CommitHash } from '@/types/git';
|
||||
import type { CommitHash } from '@/types/git';
|
||||
|
||||
interface UseGitOperationsResult {
|
||||
handlePull: () => Promise<boolean>;
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import { useState, useCallback } from 'react';
|
||||
import { notifications } from '@mantine/notifications';
|
||||
import { updateProfile, deleteUser } from '../api/user';
|
||||
import { User } from '../types/authApi';
|
||||
import { UpdateProfileRequest } from '../types/userApi';
|
||||
import type { User } from '../types/authApi';
|
||||
import type { UpdateProfileRequest } from '../types/userApi';
|
||||
|
||||
interface UseProfileSettingsResult {
|
||||
loading: boolean;
|
||||
|
||||
@@ -5,8 +5,8 @@ import {
|
||||
deleteUser as adminDeleteUser,
|
||||
} from '../api/admin';
|
||||
import { notifications } from '@mantine/notifications';
|
||||
import { User } from '../types/authApi';
|
||||
import { CreateUserRequest, UpdateUserRequest } from '../types/adminApi';
|
||||
import type { User } from '../types/authApi';
|
||||
import type { CreateUserRequest, UpdateUserRequest } from '../types/adminApi';
|
||||
|
||||
interface UseUserAdminResult {
|
||||
users: User[];
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { UserRole } from './authApi';
|
||||
import type { UserRole } from './authApi';
|
||||
|
||||
// CreateUserRequest holds the request fields for creating a new user
|
||||
export interface CreateUserRequest {
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import { visit } from 'unist-util-visit';
|
||||
import { InlineContainerType, MARKDOWN_REGEX } from '../types/markdown';
|
||||
import { Node } from 'unist';
|
||||
import { Parent } from 'unist';
|
||||
import { Text } from 'mdast';
|
||||
import type { Node } from 'unist';
|
||||
import type { Parent } from 'unist';
|
||||
import type { Text } from 'mdast';
|
||||
import { lookupFileByName } from '@/api/file';
|
||||
import { getFileUrl } from './fileHelpers';
|
||||
|
||||
|
||||
Reference in New Issue
Block a user