chore(web): new lint setup (#30020)

Co-authored-by: yyh <yuanyouhuilyz@gmail.com>
This commit is contained in:
Stephen Zhou
2025-12-23 16:58:55 +08:00
committed by GitHub
parent 9701a2994b
commit f2842da397
3356 changed files with 85046 additions and 81278 deletions

View File

@ -1,12 +1,6 @@
'use client'
import Tooltip from '@/app/components/base/tooltip'
import useRefreshPluginList from '@/app/components/plugins/install-plugin/hooks/use-refresh-plugin-list'
import { API_PREFIX } from '@/config'
import { useAppContext } from '@/context/app-context'
import { useGlobalPublicStore } from '@/context/global-public-context'
import { useRenderI18nObject } from '@/hooks/use-i18n'
import { cn } from '@/utils/classnames'
import { getMarketplaceUrl } from '@/utils/var'
import type { FC } from 'react'
import type { PluginDetail } from '../types'
import {
RiArrowRightUpLine,
RiBugLine,
@ -14,21 +8,28 @@ import {
RiHardDrive3Line,
RiLoginCircleLine,
} from '@remixicon/react'
import type { FC } from 'react'
import React, { useCallback, useMemo } from 'react'
import { useTranslation } from 'react-i18next'
import { gte } from 'semver'
import Tooltip from '@/app/components/base/tooltip'
import useRefreshPluginList from '@/app/components/plugins/install-plugin/hooks/use-refresh-plugin-list'
import { API_PREFIX } from '@/config'
import { useAppContext } from '@/context/app-context'
import { useGlobalPublicStore } from '@/context/global-public-context'
import { useRenderI18nObject } from '@/hooks/use-i18n'
import useTheme from '@/hooks/use-theme'
import Verified from '../base/badges/verified'
import { cn } from '@/utils/classnames'
import { getMarketplaceUrl } from '@/utils/var'
import Badge from '../../base/badge'
import { Github } from '../../base/icons/src/public/common'
import Verified from '../base/badges/verified'
import CornerMark from '../card/base/corner-mark'
import Description from '../card/base/description'
import OrgInfo from '../card/base/org-info'
import Title from '../card/base/title'
import { useCategories } from '../hooks'
import { usePluginPageContext } from '../plugin-page/context'
import { PluginCategoryEnum, type PluginDetail, PluginSource } from '../types'
import { PluginCategoryEnum, PluginSource } from '../types'
import Action from './action'
type Props = {
@ -105,27 +106,33 @@ const PluginItem: FC<Props> = ({
<div className={cn('hover-bg-components-panel-on-panel-item-bg relative z-10 rounded-xl border-[0.5px] border-components-panel-border bg-components-panel-on-panel-item-bg p-4 pb-3 shadow-xs', className)}>
<CornerMark text={categoriesMap[category].label} />
{/* Header */}
<div className='flex'>
<div className='flex h-10 w-10 items-center justify-center overflow-hidden rounded-xl border-[1px] border-components-panel-border-subtle'>
<div className="flex">
<div className="flex h-10 w-10 items-center justify-center overflow-hidden rounded-xl border-[1px] border-components-panel-border-subtle">
<img
className='h-full w-full'
className="h-full w-full"
src={iconSrc}
alt={`plugin-${plugin_unique_identifier}-logo`}
/>
</div>
<div className='ml-3 w-0 grow'>
<div className='flex h-5 items-center'>
<div className="ml-3 w-0 grow">
<div className="flex h-5 items-center">
<Title title={title} />
{verified && <Verified className='ml-0.5 h-4 w-4' text={t('plugin.marketplace.verifiedTip')} />}
{!isDifyVersionCompatible && <Tooltip popupContent={
t('plugin.difyVersionNotCompatible', { minimalDifyVersion: declarationMeta.minimum_dify_version })
}><RiErrorWarningLine color='red' className='ml-0.5 h-4 w-4 shrink-0 text-text-accent' /></Tooltip>}
<Badge className='ml-1 shrink-0'
{verified && <Verified className="ml-0.5 h-4 w-4" text={t('plugin.marketplace.verifiedTip')} />}
{!isDifyVersionCompatible && (
<Tooltip popupContent={
t('plugin.difyVersionNotCompatible', { minimalDifyVersion: declarationMeta.minimum_dify_version })
}
>
<RiErrorWarningLine color="red" className="ml-0.5 h-4 w-4 shrink-0 text-text-accent" />
</Tooltip>
)}
<Badge
className="ml-1 shrink-0"
text={source === PluginSource.github ? plugin.meta!.version : plugin.version}
hasRedCornerMark={(source === PluginSource.marketplace) && !!plugin.latest_version && plugin.latest_version !== plugin.version}
/>
</div>
<div className='flex items-center justify-between'>
<div className="flex items-center justify-between">
<Description text={descriptionText} descriptionLineRows={1}></Description>
<div onClick={e => e.stopPropagation()}>
<Action
@ -146,21 +153,21 @@ const PluginItem: FC<Props> = ({
</div>
</div>
</div>
<div className='mb-1 mt-1.5 flex h-4 items-center gap-x-2 px-4'>
<div className="mb-1 mt-1.5 flex h-4 items-center gap-x-2 px-4">
{/* Organization & Name */}
<div className='flex grow items-center overflow-hidden'>
<div className="flex grow items-center overflow-hidden">
<OrgInfo
orgName={orgName}
packageName={name}
packageNameClassName='w-auto max-w-[150px]'
packageNameClassName="w-auto max-w-[150px]"
/>
{category === PluginCategoryEnum.extension && (
<>
<div className='system-xs-regular mx-2 text-text-quaternary'>·</div>
<div className='system-xs-regular flex items-center gap-x-1 overflow-hidden text-text-tertiary'>
<RiLoginCircleLine className='size-3 shrink-0' />
<div className="system-xs-regular mx-2 text-text-quaternary">·</div>
<div className="system-xs-regular flex items-center gap-x-1 overflow-hidden text-text-tertiary">
<RiLoginCircleLine className="size-3 shrink-0" />
<span
className='truncate'
className="truncate"
title={t('plugin.endpointsEnabled', { num: endpoints_active })}
>
{t('plugin.endpointsEnabled', { num: endpoints_active })}
@ -170,49 +177,57 @@ const PluginItem: FC<Props> = ({
)}
</div>
{/* Source */}
<div className='flex shrink-0 items-center'>
<div className="flex shrink-0 items-center">
{source === PluginSource.github
&& <>
<a href={`https://github.com/${meta!.repo}`} target='_blank' className='flex items-center gap-1'>
<div className='system-2xs-medium-uppercase text-text-tertiary'>{t('plugin.from')}</div>
<div className='flex items-center space-x-0.5 text-text-secondary'>
<Github className='h-3 w-3' />
<div className='system-2xs-semibold-uppercase'>GitHub</div>
<RiArrowRightUpLine className='h-3 w-3' />
</div>
</a>
</>
}
&& (
<>
<a href={`https://github.com/${meta!.repo}`} target="_blank" className="flex items-center gap-1">
<div className="system-2xs-medium-uppercase text-text-tertiary">{t('plugin.from')}</div>
<div className="flex items-center space-x-0.5 text-text-secondary">
<Github className="h-3 w-3" />
<div className="system-2xs-semibold-uppercase">GitHub</div>
<RiArrowRightUpLine className="h-3 w-3" />
</div>
</a>
</>
)}
{source === PluginSource.marketplace && enable_marketplace
&& <>
<a href={getMarketplaceUrl(`/plugins/${author}/${name}`, { theme })} target='_blank' className='flex items-center gap-0.5'>
<div className='system-2xs-medium-uppercase text-text-tertiary'>{t('plugin.from')} <span className='text-text-secondary'>marketplace</span></div>
<RiArrowRightUpLine className='h-3 w-3 text-text-secondary' />
</a>
</>
}
&& (
<>
<a href={getMarketplaceUrl(`/plugins/${author}/${name}`, { theme })} target="_blank" className="flex items-center gap-0.5">
<div className="system-2xs-medium-uppercase text-text-tertiary">
{t('plugin.from')}
{' '}
<span className="text-text-secondary">marketplace</span>
</div>
<RiArrowRightUpLine className="h-3 w-3 text-text-secondary" />
</a>
</>
)}
{source === PluginSource.local
&& <>
<div className='flex items-center gap-1'>
<RiHardDrive3Line className='h-3 w-3 text-text-tertiary' />
<div className='system-2xs-medium-uppercase text-text-tertiary'>Local Plugin</div>
</div>
</>
}
&& (
<>
<div className="flex items-center gap-1">
<RiHardDrive3Line className="h-3 w-3 text-text-tertiary" />
<div className="system-2xs-medium-uppercase text-text-tertiary">Local Plugin</div>
</div>
</>
)}
{source === PluginSource.debugging
&& <>
<div className='flex items-center gap-1'>
<RiBugLine className='h-3 w-3 text-text-warning' />
<div className='system-2xs-medium-uppercase text-text-warning'>Debugging Plugin</div>
</div>
</>
}
&& (
<>
<div className="flex items-center gap-1">
<RiBugLine className="h-3 w-3 text-text-warning" />
<div className="system-2xs-medium-uppercase text-text-warning">Debugging Plugin</div>
</div>
</>
)}
</div>
{/* Deprecated */}
{source === PluginSource.marketplace && enable_marketplace && isDeprecated && (
<div className='system-2xs-medium-uppercase flex shrink-0 items-center gap-x-2'>
<span className='text-text-tertiary'>·</span>
<span className='text-text-warning'>
<div className="system-2xs-medium-uppercase flex shrink-0 items-center gap-x-2">
<span className="text-text-tertiary">·</span>
<span className="text-text-warning">
{t('plugin.deprecated')}
</span>
</div>
@ -220,7 +235,7 @@ const PluginItem: FC<Props> = ({
</div>
{/* BG Effect for Deprecated Plugin */}
{source === PluginSource.marketplace && enable_marketplace && isDeprecated && (
<div className='absolute bottom-[-71px] right-[-45px] z-0 size-40 bg-components-badge-status-light-warning-halo opacity-60 blur-[120px]' />
<div className="absolute bottom-[-71px] right-[-45px] z-0 size-40 bg-components-badge-status-light-warning-halo opacity-60 blur-[120px]" />
)}
</div>
)