chore: add 'no-empty-function': 'error' to eslint.config.mjs (#17656)

This commit is contained in:
yusheng chen 2025-04-09 12:10:17 +08:00 committed by GitHub
parent f1e4d5ed6c
commit f633d1ee92
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
16 changed files with 32 additions and 34 deletions

View File

@ -25,6 +25,7 @@ import { useSelectedDatasetsMode } from '@/app/components/workflow/nodes/knowled
import Switch from '@/app/components/base/switch' import Switch from '@/app/components/base/switch'
import Toast from '@/app/components/base/toast' import Toast from '@/app/components/base/toast'
import Divider from '@/app/components/base/divider' import Divider from '@/app/components/base/divider'
import { noop } from 'lodash-es'
type Props = { type Props = {
datasetConfigs: DatasetConfigs datasetConfigs: DatasetConfigs
@ -41,8 +42,8 @@ const ConfigContent: FC<Props> = ({
onChange, onChange,
isInWorkflow, isInWorkflow,
singleRetrievalModelConfig: singleRetrievalConfig = {} as ModelConfig, singleRetrievalModelConfig: singleRetrievalConfig = {} as ModelConfig,
onSingleRetrievalModelChange = () => { }, onSingleRetrievalModelChange = noop,
onSingleRetrievalModelParamsChange = () => { }, onSingleRetrievalModelParamsChange = noop,
selectedDatasets = [], selectedDatasets = [],
}) => { }) => {
const { t } = useTranslation() const { t } = useTranslation()

View File

@ -197,9 +197,6 @@ const Configuration: FC = () => {
const isOpenAI = modelConfig.provider === 'langgenius/openai/openai' const isOpenAI = modelConfig.provider === 'langgenius/openai/openai'
const [collectionList, setCollectionList] = useState<Collection[]>([]) const [collectionList, setCollectionList] = useState<Collection[]>([])
useEffect(() => {
}, [])
const [datasetConfigs, doSetDatasetConfigs] = useState<DatasetConfigs>({ const [datasetConfigs, doSetDatasetConfigs] = useState<DatasetConfigs>({
retrieval_model: RETRIEVE_TYPE.multiWay, retrieval_model: RETRIEVE_TYPE.multiWay,
reranking_model: { reranking_model: {

View File

@ -12,9 +12,6 @@ export class AudioPlayerManager {
private audioPlayers: AudioPlayer | null = null private audioPlayers: AudioPlayer | null = null
private msgId: string | undefined private msgId: string | undefined
private constructor() {
}
public static getInstance(): AudioPlayerManager { public static getInstance(): AudioPlayerManager {
if (!AudioPlayerManager.instance) { if (!AudioPlayerManager.instance) {
AudioPlayerManager.instance = new AudioPlayerManager() AudioPlayerManager.instance = new AudioPlayerManager()
@ -24,7 +21,7 @@ export class AudioPlayerManager {
return AudioPlayerManager.instance return AudioPlayerManager.instance
} }
public getAudioPlayer(url: string, isPublic: boolean, id: string | undefined, msgContent: string | null | undefined, voice: string | undefined, callback: ((event: string) => {}) | null): AudioPlayer { public getAudioPlayer(url: string, isPublic: boolean, id: string | undefined, msgContent: string | null | undefined, voice: string | undefined, callback: ((event: string) => void) | null): AudioPlayer {
if (this.msgId && this.msgId === id && this.audioPlayers) { if (this.msgId && this.msgId === id && this.audioPlayers) {
this.audioPlayers.setCallback(callback) this.audioPlayers.setCallback(callback)
return this.audioPlayers return this.audioPlayers

View File

@ -21,9 +21,9 @@ export default class AudioPlayer {
isLoadData = false isLoadData = false
url: string url: string
isPublic: boolean isPublic: boolean
callback: ((event: string) => {}) | null callback: ((event: string) => void) | null
constructor(streamUrl: string, isPublic: boolean, msgId: string | undefined, msgContent: string | null | undefined, voice: string | undefined, callback: ((event: string) => {}) | null) { constructor(streamUrl: string, isPublic: boolean, msgId: string | undefined, msgContent: string | null | undefined, voice: string | undefined, callback: ((event: string) => void) | null) {
this.audioContext = new AudioContext() this.audioContext = new AudioContext()
this.msgId = msgId this.msgId = msgId
this.msgContent = msgContent this.msgContent = msgContent
@ -68,7 +68,7 @@ export default class AudioPlayer {
}) })
} }
public setCallback(callback: ((event: string) => {}) | null) { public setCallback(callback: ((event: string) => void) | null) {
this.callback = callback this.callback = callback
if (callback) { if (callback) {
this.audio.addEventListener('ended', () => { this.audio.addEventListener('ended', () => {
@ -211,10 +211,6 @@ export default class AudioPlayer {
this.audioContext.suspend() this.audioContext.suspend()
} }
private cancer() {
}
private receiveAudioData(unit8Array: Uint8Array) { private receiveAudioData(unit8Array: Uint8Array) {
if (!unit8Array) { if (!unit8Array) {
this.finishStream() this.finishStream()

View File

@ -34,6 +34,7 @@ import {
getProcessedFiles, getProcessedFiles,
getProcessedFilesFromResponse, getProcessedFilesFromResponse,
} from '@/app/components/base/file-uploader/utils' } from '@/app/components/base/file-uploader/utils'
import { noop } from 'lodash-es'
type GetAbortController = (abortController: AbortController) => void type GetAbortController = (abortController: AbortController) => void
type SendCallback = { type SendCallback = {
@ -308,7 +309,7 @@ export const useChat = (
else else
ttsUrl = `/apps/${params.appId}/text-to-audio` ttsUrl = `/apps/${params.appId}/text-to-audio`
} }
const player = AudioPlayerManager.getInstance().getAudioPlayer(ttsUrl, ttsIsPublic, uuidV4(), 'none', 'none', (_: any): any => { }) const player = AudioPlayerManager.getInstance().getAudioPlayer(ttsUrl, ttsIsPublic, uuidV4(), 'none', 'none', noop)
ssePost( ssePost(
url, url,
{ {

View File

@ -7,10 +7,11 @@ import type {
IPaginationProps, IPaginationProps,
PageButtonProps, PageButtonProps,
} from './type' } from './type'
import { noop } from 'lodash-es'
const defaultState: IPagination = { const defaultState: IPagination = {
currentPage: 0, currentPage: 0,
setCurrentPage: () => {}, setCurrentPage: noop,
truncableText: '...', truncableText: '...',
truncableClassName: '', truncableClassName: '',
pages: [], pages: [],

View File

@ -62,6 +62,7 @@ import Tooltip from '@/app/components/base/tooltip'
import CustomDialog from '@/app/components/base/dialog' import CustomDialog from '@/app/components/base/dialog'
import { PortalToFollowElem, PortalToFollowElemContent, PortalToFollowElemTrigger } from '@/app/components/base/portal-to-follow-elem' import { PortalToFollowElem, PortalToFollowElemContent, PortalToFollowElemTrigger } from '@/app/components/base/portal-to-follow-elem'
import { AlertTriangle } from '@/app/components/base/icons/src/vender/solid/alertsAndFeedback' import { AlertTriangle } from '@/app/components/base/icons/src/vender/solid/alertsAndFeedback'
import { noop } from 'lodash-es'
const TextLabel: FC<PropsWithChildren> = (props) => { const TextLabel: FC<PropsWithChildren> = (props) => {
return <label className='system-sm-semibold text-text-secondary'>{props.children}</label> return <label className='system-sm-semibold text-text-secondary'>{props.children}</label>
@ -1010,7 +1011,7 @@ const StepTwo = ({
</div> </div>
)} )}
</div> </div>
<FloatRightContainer isMobile={isMobile} isOpen={true} onClose={() => { }} footer={null}> <FloatRightContainer isMobile={isMobile} isOpen={true} onClose={noop} footer={null}>
<PreviewContainer <PreviewContainer
header={<PreviewHeader header={<PreviewHeader
title={t('datasetCreation.stepTwo.preview')} title={t('datasetCreation.stepTwo.preview')}

View File

@ -46,6 +46,7 @@ import { useDocumentArchive, useDocumentDelete, useDocumentDisable, useDocumentE
import { extensionToFileType } from '@/app/components/datasets/hit-testing/utils/extension-to-file-type' import { extensionToFileType } from '@/app/components/datasets/hit-testing/utils/extension-to-file-type'
import useBatchEditDocumentMetadata from '../metadata/hooks/use-batch-edit-document-metadata' import useBatchEditDocumentMetadata from '../metadata/hooks/use-batch-edit-document-metadata'
import EditMetadataBatchModal from '@/app/components/datasets/metadata/edit-metadata-batch/modal' import EditMetadataBatchModal from '@/app/components/datasets/metadata/edit-metadata-batch/modal'
import { noop } from 'lodash-es'
export const useIndexStatus = () => { export const useIndexStatus = () => {
const { t } = useTranslation() const { t } = useTranslation()
@ -265,7 +266,7 @@ export const OperationAction: FC<{
return <div className='flex items-center' onClick={e => e.stopPropagation()}> return <div className='flex items-center' onClick={e => e.stopPropagation()}>
{isListScene && !embeddingAvailable && ( {isListScene && !embeddingAvailable && (
<Switch defaultValue={false} onChange={() => { }} disabled={true} size='md' /> <Switch defaultValue={false} onChange={noop} disabled={true} size='md' />
)} )}
{isListScene && embeddingAvailable && ( {isListScene && embeddingAvailable && (
<> <>
@ -276,7 +277,7 @@ export const OperationAction: FC<{
needsDelay needsDelay
> >
<div> <div>
<Switch defaultValue={false} onChange={() => { }} disabled={true} size='md' /> <Switch defaultValue={false} onChange={noop} disabled={true} size='md' />
</div> </div>
</Tooltip> </Tooltip>
: <Switch defaultValue={enabled} onChange={v => handleSwitch(v ? 'enable' : 'disable')} size='md' /> : <Switch defaultValue={enabled} onChange={v => handleSwitch(v ? 'enable' : 'disable')} size='md' />

View File

@ -13,6 +13,7 @@ import AppIcon from '@/app/components/base/app-icon'
import { useProviderContext } from '@/context/provider-context' import { useProviderContext } from '@/context/provider-context'
import AppsFull from '@/app/components/billing/apps-full-in-dialog' import AppsFull from '@/app/components/billing/apps-full-in-dialog'
import type { AppIconType } from '@/types/app' import type { AppIconType } from '@/types/app'
import { noop } from 'lodash-es'
export type CreateAppModalProps = { export type CreateAppModalProps = {
show: boolean show: boolean
@ -85,7 +86,7 @@ const CreateAppModal = ({
<> <>
<Modal <Modal
isShow={show} isShow={show}
onClose={() => {}} onClose={noop}
className='relative !max-w-[480px] px-8' className='relative !max-w-[480px] px-8'
> >
<div className='absolute right-4 top-4 cursor-pointer p-2' onClick={onHide}> <div className='absolute right-4 top-4 cursor-pointer p-2' onClick={onHide}>

View File

@ -10,6 +10,7 @@ import Operate from '../data-source-notion/operate'
import { DataSourceType } from './types' import { DataSourceType } from './types'
import s from './style.module.css' import s from './style.module.css'
import cn from '@/utils/classnames' import cn from '@/utils/classnames'
import { noop } from 'lodash-es'
export type ConfigItemType = { export type ConfigItemType = {
id: string id: string
@ -41,7 +42,7 @@ const ConfigItem: FC<Props> = ({
const { t } = useTranslation() const { t } = useTranslation()
const isNotion = type === DataSourceType.notion const isNotion = type === DataSourceType.notion
const isWebsite = type === DataSourceType.website const isWebsite = type === DataSourceType.website
const onChangeAuthorizedPage = notionActions?.onChangeAuthorizedPage || function () { } const onChangeAuthorizedPage = notionActions?.onChangeAuthorizedPage || noop
return ( return (
<div className={cn(s['workspace-item'], 'mb-1 flex items-center rounded-lg bg-components-panel-on-panel-item-bg py-1 pr-1')} key={payload.id}> <div className={cn(s['workspace-item'], 'mb-1 flex items-center rounded-lg bg-components-panel-on-panel-item-bg py-1 pr-1')} key={payload.id}>

View File

@ -9,6 +9,7 @@ import Link from 'next/link'
import { marketplaceUrlPrefix } from '@/config' import { marketplaceUrlPrefix } from '@/config'
import { RiArrowRightUpLine, RiSearchLine } from '@remixicon/react' import { RiArrowRightUpLine, RiSearchLine } from '@remixicon/react'
// import { RiArrowRightUpLine } from '@remixicon/react' // import { RiArrowRightUpLine } from '@remixicon/react'
import { noop } from 'lodash-es'
type Props = { type Props = {
wrapElemRef: React.RefObject<HTMLElement> wrapElemRef: React.RefObject<HTMLElement>
@ -107,7 +108,7 @@ const List = (
<Item <Item
key={index} key={index}
payload={item} payload={item}
onAction={() => { }} onAction={noop}
/> />
))} ))}
<div className='mb-3 mt-2 flex items-center justify-center space-x-2'> <div className='mb-3 mt-2 flex items-center justify-center space-x-2'>

View File

@ -18,6 +18,7 @@ import { stopWorkflowRun } from '@/service/workflow'
import { useFeaturesStore } from '@/app/components/base/features/hooks' import { useFeaturesStore } from '@/app/components/base/features/hooks'
import { AudioPlayerManager } from '@/app/components/base/audio-btn/audio.player.manager' import { AudioPlayerManager } from '@/app/components/base/audio-btn/audio.player.manager'
import type { VersionHistory } from '@/types/workflow' import type { VersionHistory } from '@/types/workflow'
import { noop } from 'lodash-es'
export const useWorkflowRun = () => { export const useWorkflowRun = () => {
const store = useStoreApi() const store = useStoreApi()
@ -168,7 +169,7 @@ export const useWorkflowRun = () => {
else else
ttsUrl = `/apps/${params.appId}/text-to-audio` ttsUrl = `/apps/${params.appId}/text-to-audio`
} }
const player = AudioPlayerManager.getInstance().getAudioPlayer(ttsUrl, ttsIsPublic, uuidV4(), 'none', 'none', (_: any): any => { }) const player = AudioPlayerManager.getInstance().getAudioPlayer(ttsUrl, ttsIsPublic, uuidV4(), 'none', 'none', noop)
ssePost( ssePost(
url, url,

View File

@ -30,7 +30,7 @@ import IterationDefault from '@/app/components/workflow/nodes/iteration/default'
import DocumentExtractorDefault from '@/app/components/workflow/nodes/document-extractor/default' import DocumentExtractorDefault from '@/app/components/workflow/nodes/document-extractor/default'
import LoopDefault from '@/app/components/workflow/nodes/loop/default' import LoopDefault from '@/app/components/workflow/nodes/loop/default'
import { ssePost } from '@/service/base' import { ssePost } from '@/service/base'
import { noop } from 'lodash-es'
import { getInputVars as doGetInputVars } from '@/app/components/base/prompt-editor/constants' import { getInputVars as doGetInputVars } from '@/app/components/base/prompt-editor/constants'
import type { NodeTracing } from '@/types/workflow' import type { NodeTracing } from '@/types/workflow'
const { checkValid: checkLLMValid } = LLMDefault const { checkValid: checkLLMValid } = LLMDefault
@ -233,8 +233,7 @@ const useOneStepRun = <T>({
getIterationSingleNodeRunUrl(isChatMode, appId!, id), getIterationSingleNodeRunUrl(isChatMode, appId!, id),
{ body: { inputs: submitData } }, { body: { inputs: submitData } },
{ {
onWorkflowStarted: () => { onWorkflowStarted: noop,
},
onWorkflowFinished: (params) => { onWorkflowFinished: (params) => {
handleNodeDataUpdate({ handleNodeDataUpdate({
id, id,
@ -331,8 +330,7 @@ const useOneStepRun = <T>({
getLoopSingleNodeRunUrl(isChatMode, appId!, id), getLoopSingleNodeRunUrl(isChatMode, appId!, id),
{ body: { inputs: submitData } }, { body: { inputs: submitData } },
{ {
onWorkflowStarted: () => { onWorkflowStarted: noop,
},
onWorkflowFinished: (params) => { onWorkflowFinished: (params) => {
handleNodeDataUpdate({ handleNodeDataUpdate({
id, id,

View File

@ -177,6 +177,3 @@ export const multiStepsCircle = (() => {
}], }],
} }
})() })()
export const CircleNestCircle = (() => {
})()

View File

@ -4,6 +4,7 @@ import {
} from 'use-context-selector' } from 'use-context-selector'
import type { Locale } from '@/i18n' import type { Locale } from '@/i18n'
import { getLanguage } from '@/i18n/language' import { getLanguage } from '@/i18n/language'
import { noop } from 'lodash-es'
type II18NContext = { type II18NContext = {
locale: Locale locale: Locale
@ -14,7 +15,7 @@ type II18NContext = {
const I18NContext = createContext<II18NContext>({ const I18NContext = createContext<II18NContext>({
locale: 'en-US', locale: 'en-US',
i18n: {}, i18n: {},
setLocaleOnClient: (_lang: Locale, _reloadPage?: boolean) => { }, setLocaleOnClient: noop,
}) })
export const useI18N = () => useContext(I18NContext) export const useI18N = () => useContext(I18NContext)

View File

@ -117,6 +117,9 @@ export default combine(
// antfu migrate to eslint-plugin-unused-imports // antfu migrate to eslint-plugin-unused-imports
'unused-imports/no-unused-vars': 'warn', 'unused-imports/no-unused-vars': 'warn',
'unused-imports/no-unused-imports': 'warn', 'unused-imports/no-unused-imports': 'warn',
// We use `import { noop } from 'lodash-es'` across `web` project
'no-empty-function': 'error',
}, },
languageOptions: { languageOptions: {