Skip to content

Commit

Permalink
chore: lint & format
Browse files Browse the repository at this point in the history
  • Loading branch information
GZTimeWalker committed Dec 10, 2024
1 parent fb2a667 commit a0905f8
Show file tree
Hide file tree
Showing 89 changed files with 362 additions and 1,309 deletions.
3 changes: 0 additions & 3 deletions src/GZCTF/ClientApp/eslint.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,6 @@ export default [

rules: {
'@typescript-eslint/no-explicit-any': 'off',
'@typescript-eslint/no-non-null-asserted-optional-chain': 'off',
'@typescript-eslint/no-non-null-assertion': 'off',
'@typescript-eslint/no-unused-expressions': 'off',
'react-hooks/exhaustive-deps': 'off',
'react/display-name': 'off',
'react/jsx-key': 'off',
Expand Down
2 changes: 1 addition & 1 deletion src/GZCTF/ClientApp/prettier.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export default {
singleQuote: true,
trailingComma: 'es5',
semi: false,
printWidth: 100,
printWidth: 120,
htmlWhitespaceSensitivity: 'ignore',
jsonRecursiveSort: true,
plugins: ['@trivago/prettier-plugin-sort-imports', 'prettier-plugin-sort-json'],
Expand Down
4 changes: 1 addition & 3 deletions src/GZCTF/ClientApp/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,7 @@ export const App: FC = () => {
<ErrorBoundary FallbackComponent={ErrorFallback}>
<Notifications zIndex={5000} />
<DatesProvider settings={{ locale }}>
<ModalsProvider
labels={{ confirm: t('common.modal.confirm'), cancel: t('common.modal.cancel') }}
>
<ModalsProvider labels={{ confirm: t('common.modal.confirm'), cancel: t('common.modal.cancel') }}>
<SWRConfig
value={{
refreshInterval: 10000,
Expand Down
19 changes: 2 additions & 17 deletions src/GZCTF/ClientApp/src/components/ActionIconWithConfirm.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,4 @@
import {
ActionIcon,
Button,
Group,
MantineColor,
MantineSpacing,
Popover,
Stack,
Text,
} from '@mantine/core'
import { ActionIcon, Button, Group, MantineColor, MantineSpacing, Popover, Stack, Text } from '@mantine/core'
import { Icon } from '@mdi/react'
import { FC, useState } from 'react'
import { useTranslation } from 'react-i18next'
Expand Down Expand Up @@ -48,13 +39,7 @@ export const ActionIconWithConfirm: FC<ActionIconWithConfirmProps> = (props) =>
</Text>

<Group w="100%" justify="space-between">
<Button
size="xs"
py={2}
variant="outline"
disabled={props.disabled}
onClick={() => setOpened(false)}
>
<Button size="xs" py={2} variant="outline" disabled={props.disabled} onClick={() => setOpened(false)}>
{t('common.modal.cancel')}
</Button>
<Button
Expand Down
25 changes: 4 additions & 21 deletions src/GZCTF/ClientApp/src/components/AppHeader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -55,24 +55,14 @@ export const AppHeader: FC<AppControlProps> = ({ openColorModal }) => {
))}
</Menu.Dropdown>
</Menu>
<Menu
shadow="md"
opened={opened}
onClose={() => setOpened(false)}
width={200}
offset={13}
>
<Menu shadow="md" opened={opened} onClose={() => setOpened(false)} width={200} offset={13}>
<Menu.Target>
<Burger opened={opened} onClick={() => setOpened((o) => !o)} />
</Menu.Target>
<Menu.Dropdown>
{user && !error ? (
<>
<Menu.Item
component={Link}
to="/teams"
leftSection={<Icon path={mdiAccountGroupOutline} size={1} />}
>
<Menu.Item component={Link} to="/teams" leftSection={<Icon path={mdiAccountGroupOutline} size={1} />}>
{t('common.tab.team')}
</Menu.Item>
<Menu.Item
Expand All @@ -82,11 +72,7 @@ export const AppHeader: FC<AppControlProps> = ({ openColorModal }) => {
>
{t('common.tab.account.profile')}
</Menu.Item>
<Menu.Item
color="red"
onClick={logout}
leftSection={<Icon path={mdiLogout} size={1} />}
>
<Menu.Item color="red" onClick={logout} leftSection={<Icon path={mdiLogout} size={1} />}>
{t('common.tab.account.logout')}
</Menu.Item>
</>
Expand All @@ -112,10 +98,7 @@ export const AppHeader: FC<AppControlProps> = ({ openColorModal }) => {
onClick={() => toggleColorScheme()}
>
{t('common.tab.theme.switch_to', {
theme:
colorScheme === 'dark'
? t('common.tab.theme.light')
: t('common.tab.theme.dark'),
theme: colorScheme === 'dark' ? t('common.tab.theme.light') : t('common.tab.theme.dark'),
})}
</Menu.Item>
<Menu.Item onClick={clearLocalCache} leftSection={<Icon path={mdiCached} size={1} />}>
Expand Down
24 changes: 4 additions & 20 deletions src/GZCTF/ClientApp/src/components/AppNavbar.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,4 @@
import {
ActionIcon,
AppShell,
Avatar,
Menu,
MenuDivider,
Stack,
Tooltip,
useMantineColorScheme,
} from '@mantine/core'
import { ActionIcon, AppShell, Avatar, Menu, MenuDivider, Stack, Tooltip, useMantineColorScheme } from '@mantine/core'
import {
mdiAccountCircleOutline,
mdiAccountGroupOutline,
Expand Down Expand Up @@ -122,9 +113,7 @@ export const AppNavbar: FC<AppControlProps> = ({ openColorModal }) => {
</AppShell.Section>

{/* Common Nav */}
<AppShell.Section className={cx(classes.section, misc.justifyCenter)}>
{links}
</AppShell.Section>
<AppShell.Section className={cx(classes.section, misc.justifyCenter)}>{links}</AppShell.Section>

<AppShell.Section className={cx(classes.section, misc.justifyEnd)}>
<Stack w="100%" align="center" justify="center" gap={5}>
Expand All @@ -148,8 +137,7 @@ export const AppNavbar: FC<AppControlProps> = ({ openColorModal }) => {
{/* Color Mode */}
<Tooltip
label={t('common.tab.theme.switch_to', {
theme:
colorScheme === 'dark' ? t('common.tab.theme.light') : t('common.tab.theme.dark'),
theme: colorScheme === 'dark' ? t('common.tab.theme.light') : t('common.tab.theme.dark'),
})}
classNames={classes}
position="right"
Expand Down Expand Up @@ -197,11 +185,7 @@ export const AppNavbar: FC<AppControlProps> = ({ openColorModal }) => {
</Menu.Item>
<MenuDivider />
{loggedIn ? (
<Menu.Item
color="red"
onClick={logout}
leftSection={<Icon path={mdiLogout} size={1} />}
>
<Menu.Item color="red" onClick={logout} leftSection={<Icon path={mdiLogout} size={1} />}>
{t('common.tab.account.logout')}
</Menu.Item>
) : (
Expand Down
7 changes: 2 additions & 5 deletions src/GZCTF/ClientApp/src/components/ChallengeModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -66,16 +66,13 @@ export const ChallengeModal: FC<ChallengeModalProps> = (props) => {
}, [challenge])

const isContainer =
challenge?.type === ChallengeType.StaticContainer ||
challenge?.type === ChallengeType.DynamicContainer
challenge?.type === ChallengeType.StaticContainer || challenge?.type === ChallengeType.DynamicContainer

const title = (
<Stack gap="xs">
<Group wrap="nowrap" w="100%" justify="space-between" gap="sm">
<Group wrap="nowrap" gap="sm" w="calc(100% - 6.75rem)">
{cateData && (
<Icon path={cateData.icon} size={1.2} color={theme.colors[cateData?.color][5]} />
)}
{cateData && <Icon path={cateData.icon} size={1.2} color={theme.colors[cateData?.color][5]} />}
<Title order={4} lineClamp={1}>
{challenge?.title ?? ''}
</Title>
Expand Down
14 changes: 3 additions & 11 deletions src/GZCTF/ClientApp/src/components/ChallengePanel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,7 @@ export const ChallengePanel: FC = () => {
challenges &&
(activeTab !== 'All' ? (challenges[activeTab] ?? []) : allChallenges).filter(
(chal) =>
!hideSolved ||
(teamInfo && teamInfo.rank?.solvedChallenges?.find((c) => c.id === chal.id)) === undefined
!hideSolved || (teamInfo && teamInfo.rank?.solvedChallenges?.find((c) => c.id === chal.id)) === undefined
)

const [challenge, setChallenge] = useState<ChallengeInfo | null>(null)
Expand Down Expand Up @@ -194,12 +193,7 @@ export const ChallengePanel: FC = () => {
{categories.map((tab) => {
const data = challengeCategoryLabelMap.get(tab as ChallengeCategory)!
return (
<Tabs.Tab
key={tab}
value={tab}
leftSection={<Icon path={data?.icon} size={1} />}
color={data?.color}
>
<Tabs.Tab key={tab} value={tab} leftSection={<Icon path={data?.icon} size={1} />} color={data?.color}>
<Group justify="space-between" wrap="nowrap" gap={2}>
<Text fz="sm" fw="bold">
{data?.name}
Expand Down Expand Up @@ -290,9 +284,7 @@ export const ChallengePanel: FC = () => {
gameEnded={dayjs(game?.end) < dayjs()}
status={teamInfo?.rank?.solvedChallenges?.find((c) => c.id === challenge?.id)?.type}
cateData={
challengeCategoryLabelMap.get(
(challenge?.category as ChallengeCategory) ?? ChallengeCategory.Misc
)!
challengeCategoryLabelMap.get((challenge?.category as ChallengeCategory) ?? ChallengeCategory.Misc)!
}
title={challenge?.title ?? ''}
score={challenge?.score ?? 0}
Expand Down
17 changes: 2 additions & 15 deletions src/GZCTF/ClientApp/src/components/CustomColorModal.tsx
Original file line number Diff line number Diff line change
@@ -1,15 +1,5 @@
import { generateColors } from '@mantine/colors-generator'
import {
Text,
ColorInput,
Group,
Modal,
ModalProps,
Radio,
Stack,
InputBase,
useMantineTheme,
} from '@mantine/core'
import { Text, ColorInput, Group, Modal, ModalProps, Radio, Stack, InputBase, useMantineTheme } from '@mantine/core'
import { useDebouncedValue } from '@mantine/hooks'
import { FC, useEffect, useState } from 'react'
import { useTranslation } from 'react-i18next'
Expand All @@ -29,10 +19,7 @@ export const CustomColorModal: FC<ModalProps> = (props) => {

const valid = colorRegex.test(color.color)

const colors =
color.provider === ColorProvider.Custom && valid
? generateColors(color.color)
: theme.colors.brand
const colors = color.provider === ColorProvider.Custom && valid ? generateColors(color.color) : theme.colors.brand

useEffect(() => {
setColor(customColor)
Expand Down
4 changes: 1 addition & 3 deletions src/GZCTF/ClientApp/src/components/GameCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,7 @@ export const GameCard: FC<GameCardProps> = ({ game, ...others }) => {
<Card.Section>
<Group wrap="nowrap" align="flex-start">
<BackgroundImage src={poster ?? ''} h="10rem" maw="20rem" miw="20rem">
<Center h="100%">
{!poster && <Icon path={mdiFlagOutline} size={4} color={theme.colors.gray[5]} />}
</Center>
<Center h="100%">{!poster && <Icon path={mdiFlagOutline} size={4} color={theme.colors.gray[5]} />}</Center>
</BackgroundImage>
<Stack gap="sm" p="md" w="100%">
<Group gap={0} justify="space-between" align="flex-start">
Expand Down
3 changes: 1 addition & 2 deletions src/GZCTF/ClientApp/src/components/GameChallengeModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,7 @@ export const GameChallengeModal: FC<GameChallengeModalProps> = (props) => {
}) as string[]

const isDynamic =
challenge?.type === ChallengeType.StaticContainer ||
challenge?.type === ChallengeType.DynamicContainer
challenge?.type === ChallengeType.StaticContainer || challenge?.type === ChallengeType.DynamicContainer

const [disabled, setDisabled] = useState(false)
const [submitId, setSubmitId] = useState(0)
Expand Down
23 changes: 3 additions & 20 deletions src/GZCTF/ClientApp/src/components/GameNoticePanel.tsx
Original file line number Diff line number Diff line change
@@ -1,15 +1,5 @@
import {
Card,
Center,
List,
ScrollArea,
SegmentedControl,
Stack,
Text,
useMantineTheme,
} from '@mantine/core'
import { Card, Center, List, ScrollArea, SegmentedControl, Stack, Text, useMantineTheme } from '@mantine/core'
import { showNotification } from '@mantine/notifications'
import { mdiClose } from '@mdi/js'
import { Icon } from '@mdi/react'
import * as signalR from '@microsoft/signalr'
import dayjs from 'dayjs'
Expand Down Expand Up @@ -38,9 +28,7 @@ const ApplyFilter = (notices: GameNotice[], filter: NoticeFilter) => {
case NoticeFilter.All:
return notices
case NoticeFilter.Challenge:
return notices.filter(
(notice) => notice.type === NoticeType.NewChallenge || notice.type === NoticeType.NewHint
)
return notices.filter((notice) => notice.type === NoticeType.NewChallenge || notice.type === NoticeType.NewHint)
case NoticeFilter.Events:
return notices.filter(
(notice) =>
Expand Down Expand Up @@ -192,12 +180,7 @@ export const GameNoticePanel: FC = () => {
{dayjs(notice.time).locale(locale).format('SLL LTS')}
</Text>
{notice.type === NoticeType.Normal ? (
<InlineMarkdown
fz="sm"
fw={500}
c="dimmed"
source={formatNotice(t, notice)}
/>
<InlineMarkdown fz="sm" fw={500} c="dimmed" source={formatNotice(t, notice)} />
) : (
<Text fz="sm" fw={500} c="dimmed" className={typoClasses.inline}>
{formatNotice(t, notice)}
Expand Down
16 changes: 2 additions & 14 deletions src/GZCTF/ClientApp/src/components/GameProgress.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,4 @@
import {
BoxProps,
Center,
Group,
MantineColor,
em,
useMantineColorScheme,
useMantineTheme,
} from '@mantine/core'
import { BoxProps, Center, Group, MantineColor, em, useMantineColorScheme, useMantineTheme } from '@mantine/core'
import cx from 'clsx'
import { FC } from 'react'
import classes from '@Styles/GameProgress.module.css'
Expand All @@ -25,11 +17,7 @@ export const GameProgress: FC<GameProgressProps> = (props: GameProgressProps) =>
const { colorScheme } = useMantineColorScheme()

const pulsing = percentage < 100
const resolvedColor = pulsing
? colorScheme === 'dark'
? 'light'
: (color ?? theme.primaryColor)
: 'gray'
const resolvedColor = pulsing ? (colorScheme === 'dark' ? 'light' : (color ?? theme.primaryColor)) : 'gray'
const spikeColor = theme.colors[resolvedColor][5]
const bgColor = theme.colors[resolvedColor][2]

Expand Down
10 changes: 1 addition & 9 deletions src/GZCTF/ClientApp/src/components/HintList.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,4 @@
import {
ActionIcon,
Button,
Input,
InputWrapperProps,
ScrollArea,
Stack,
TextInput,
} from '@mantine/core'
import { ActionIcon, Button, Input, InputWrapperProps, ScrollArea, Stack, TextInput } from '@mantine/core'
import { mdiClose, mdiPlus } from '@mdi/js'
import { Icon } from '@mdi/react'
import { FC } from 'react'
Expand Down
15 changes: 3 additions & 12 deletions src/GZCTF/ClientApp/src/components/IconTabs.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,4 @@
import {
Box,
Group,
GroupProps,
MantineColor,
useMantineColorScheme,
useMantineTheme,
} from '@mantine/core'
import { Box, Group, GroupProps, MantineColor, useMantineColorScheme, useMantineTheme } from '@mantine/core'
import { clamp } from '@mantine/hooks'
import React, { FC, useEffect, useState } from 'react'
import { LogoHeader } from '@Components/LogoHeader'
Expand All @@ -29,9 +22,7 @@ interface IconTabsProps extends GroupProps {
onTabChange?: (tabIndex: number, tabKey: string) => void
}

const Tab: FC<TabProps & { active: boolean; onClick?: () => void; disabled?: boolean }> = (
props
) => {
const Tab: FC<TabProps & { active: boolean; onClick?: () => void; disabled?: boolean }> = (props) => {
const { color, label, active, icon, tabKey, disabled, ...others } = props

return (
Expand Down Expand Up @@ -78,7 +69,7 @@ export const IconTabs: FC<IconTabsProps> = (props) => {
active={current === index}
onClick={() => {
setActiveTab(index)
onTabChange && onTabChange(index, tab.tabKey)
if (onTabChange) onTabChange(index, tab.tabKey)
}}
/>
))
Expand Down
Loading

0 comments on commit a0905f8

Please sign in to comment.