CI: add TS indentation check via esLint (#24810)

This commit is contained in:
Yongtao Huang 2025-09-01 15:31:59 +08:00 • committed by GitHub
commit 208ce4e774
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
118 changed files with 457 additions and 489 deletions

View file

@ -89,7 +89,9 @@ jobs:
- name: Web style check - name: Web style check
if: steps.changed-files.outputs.any_changed == 'true' if: steps.changed-files.outputs.any_changed == 'true'
working-directory: ./web working-directory: ./web
run: pnpm run lint run: |
pnpm run lint
pnpm run eslint
docker-compose-template: docker-compose-template:
name: Docker Compose Template name: Docker Compose Template

View file

@ -175,7 +175,6 @@ const ConfigContent: FC<Props> = ({
...datasetConfigs, ...datasetConfigs,
reranking_enable: enable, reranking_enable: enable,
}) })
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [currentRerankModel, datasetConfigs, onChange]) }, [currentRerankModel, datasetConfigs, onChange])
return ( return (

View file

@ -61,7 +61,6 @@ const RetrievalParamConfig: FC<Props> = ({
...value, ...value,
reranking_enable: enable, reranking_enable: enable,
}) })
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [currentModel, onChange, value]) }, [currentModel, onChange, value])
const rerankModel = useMemo(() => { const rerankModel = useMemo(() => {

View file

@ -29,7 +29,6 @@ const OptionsWrap: FC<Props> = ({
useEffect(() => { useEffect(() => {
if (controlFoldOptions) if (controlFoldOptions)
foldHide() foldHide()
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [controlFoldOptions]) }, [controlFoldOptions])
return ( return (
<div className={cn(className, !fold ? 'mb-0' : 'mb-3')}> <div className={cn(className, !fold ? 'mb-0' : 'mb-3')}>

View file

@ -64,7 +64,6 @@ const Website: FC<Props> = ({
checkSetApiKey().then(() => { checkSetApiKey().then(() => {
setIsLoaded(true) setIsLoaded(true)
}) })
// eslint-disable-next-line react-hooks/exhaustive-deps
}, []) }, [])
const handleOnConfig = useCallback(() => { const handleOnConfig = useCallback(() => {
setShowAccountSettingModal({ setShowAccountSettingModal({

View file

@ -29,7 +29,6 @@ const OptionsWrap: FC<Props> = ({
useEffect(() => { useEffect(() => {
if (controlFoldOptions) if (controlFoldOptions)
foldHide() foldHide()
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [controlFoldOptions]) }, [controlFoldOptions])
return ( return (
<div className={cn(className, !fold ? 'mb-0' : 'mb-3')}> <div className={cn(className, !fold ? 'mb-0' : 'mb-3')}>

View file

@ -69,13 +69,13 @@ const ChunkDetailModal: FC<Props> = ({
<div> <div>
<div className='flex gap-x-1'> <div className='flex gap-x-1'>
<div className='w-4 shrink-0 text-[13px] font-medium leading-[20px] text-text-tertiary'>Q</div> <div className='w-4 shrink-0 text-[13px] font-medium leading-[20px] text-text-tertiary'>Q</div>
<div className={cn('body-md-regular text-text-secondary line-clamp-20')}> <div className={cn('body-md-regular line-clamp-20 text-text-secondary')}>
{content} {content}
</div> </div>
</div> </div>
<div className='flex gap-x-1'> <div className='flex gap-x-1'>
<div className='w-4 shrink-0 text-[13px] font-medium leading-[20px] text-text-tertiary'>A</div> <div className='w-4 shrink-0 text-[13px] font-medium leading-[20px] text-text-tertiary'>A</div>
<div className={cn('body-md-regular text-text-secondary line-clamp-20')}> <div className={cn('body-md-regular line-clamp-20 text-text-secondary')}>
{answer} {answer}
</div> </div>
</div> </div>

View file

@ -28,7 +28,6 @@ const useEditDatasetMetadata = ({
showEditModal() showEditModal()
localStorage.removeItem(isShowManageMetadataLocalStorageKey) localStorage.removeItem(isShowManageMetadataLocalStorageKey)
} }
// eslint-disable-next-line react-hooks/exhaustive-deps
}, []) }, [])
const { data: datasetMetaData } = useDatasetMetaData(datasetId) const { data: datasetMetaData } = useDatasetMetaData(datasetId)

View file

@ -32,7 +32,6 @@ const DataSourceWebsite: FC<Props> = ({ provider }) => {
useEffect(() => { useEffect(() => {
checkSetApiKey() checkSetApiKey()
// eslint-disable-next-line react-hooks/exhaustive-deps
}, []) }, [])
const [configTarget, setConfigTarget] = useState<DataSourceProvider | null>(null) const [configTarget, setConfigTarget] = useState<DataSourceProvider | null>(null)

View file

@ -41,13 +41,10 @@ const Item: FC<Props> = ({
onFetchedPayload(payload) onFetchedPayload(payload)
setPayload({ ...payload, from: dependency.type }) setPayload({ ...payload, from: dependency.type })
} }
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [data]) }, [data])
useEffect(() => { useEffect(() => {
if (error) if (error)
onFetchError() onFetchError()
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [error]) }, [error])
if (!payload) return <Loading /> if (!payload) return <Loading />
return ( return (

View file

@ -131,7 +131,6 @@ const InstallByDSLList: ForwardRefRenderFunction<ExposeRefs, Props> = ({
if (failedIndex.length > 0) if (failedIndex.length > 0)
setErrorIndexes([...errorIndexes, ...failedIndex]) setErrorIndexes([...errorIndexes, ...failedIndex])
} }
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [isFetchingMarketplaceDataById]) }, [isFetchingMarketplaceDataById])
useEffect(() => { useEffect(() => {
@ -156,15 +155,12 @@ const InstallByDSLList: ForwardRefRenderFunction<ExposeRefs, Props> = ({
if (failedIndex.length > 0) if (failedIndex.length > 0)
setErrorIndexes([...errorIndexes, ...failedIndex]) setErrorIndexes([...errorIndexes, ...failedIndex])
} }
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [isFetchingDataByMeta]) }, [isFetchingDataByMeta])
useEffect(() => { useEffect(() => {
// get info all failed // get info all failed
if (infoByMetaError || infoByIdError) if (infoByMetaError || infoByIdError)
setErrorIndexes([...errorIndexes, ...marketPlaceInDSLIndex]) setErrorIndexes([...errorIndexes, ...marketPlaceInDSLIndex])
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [infoByMetaError, infoByIdError]) }, [infoByMetaError, infoByIdError])
const isLoadedAllData = (plugins.filter(p => !!p).length + errorIndexes.length) === allPlugins.length const isLoadedAllData = (plugins.filter(p => !!p).length + errorIndexes.length) === allPlugins.length
@ -189,8 +185,6 @@ const InstallByDSLList: ForwardRefRenderFunction<ExposeRefs, Props> = ({
useEffect(() => { useEffect(() => {
if (isLoadedAllData && installedInfo) if (isLoadedAllData && installedInfo)
onLoadedAllPlugin(installedInfo!) onLoadedAllPlugin(installedInfo!)
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [isLoadedAllData, installedInfo]) }, [isLoadedAllData, installedInfo])
const handleSelect = useCallback((index: number) => { const handleSelect = useCallback((index: number) => {

View file

@ -61,7 +61,6 @@ const Loaded: React.FC<LoadedProps> = ({
useEffect(() => { useEffect(() => {
if (hasInstalled && uniqueIdentifier === installedInfoPayload.uniqueIdentifier) if (hasInstalled && uniqueIdentifier === installedInfoPayload.uniqueIdentifier)
onInstalled() onInstalled()
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [hasInstalled]) }, [hasInstalled])
const handleInstall = async () => { const handleInstall = async () => {

View file

@ -55,7 +55,6 @@ const Uploading: FC<Props> = ({
React.useEffect(() => { React.useEffect(() => {
handleUpload() handleUpload()
// eslint-disable-next-line react-hooks/exhaustive-deps
}, []) }, [])
return ( return (
<> <>

View file

@ -175,7 +175,6 @@ export const MarketplaceContextProvider = ({
}) })
} }
} }
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [queryPlugins, queryMarketplaceCollectionsAndPlugins, isSuccess, exclude]) }, [queryPlugins, queryMarketplaceCollectionsAndPlugins, isSuccess, exclude])
const handleQueryMarketplaceCollectionsAndPlugins = useCallback(() => { const handleQueryMarketplaceCollectionsAndPlugins = useCallback(() => {

View file

@ -98,7 +98,6 @@ const Action: FC<Props> = ({
hideDeleteConfirm() hideDeleteConfirm()
onDelete() onDelete()
} }
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [installationId, onDelete]) }, [installationId, onDelete])
return ( return (
<div className='flex space-x-1'> <div className='flex space-x-1'>

View file

@ -141,7 +141,6 @@ const MCPDetailContent: FC<Props> = ({
useEffect(() => { useEffect(() => {
if (isTriggerAuthorize) if (isTriggerAuthorize)
handleAuthorize() handleAuthorize()
// eslint-disable-next-line react-hooks/exhaustive-deps
}, []) }, [])
if (!detail) if (!detail)

View file

@ -83,7 +83,6 @@ export const useWorkflowInit = () => {
useEffect(() => { useEffect(() => {
handleGetInitialWorkflowData() handleGetInitialWorkflowData()
// eslint-disable-next-line react-hooks/exhaustive-deps
}, []) }, [])
const handleFetchPreloadData = useCallback(async () => { const handleFetchPreloadData = useCallback(async () => {

View file

@ -101,7 +101,6 @@ const AllTools = ({
category: PluginType.tool, category: PluginType.tool,
}) })
} }
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [searchText, tags, enable_marketplace]) }, [searchText, tags, enable_marketplace])
const pluginRef = useRef<ListRef>(null) const pluginRef = useRef<ListRef>(null)

View file

@ -60,7 +60,6 @@ const OperationDropdown: FC<Props> = ({
downloadFile({ data: blob, fileName }) downloadFile({ data: blob, fileName })
setNeedDownload(false) setNeedDownload(false)
} }
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [blob]) }, [blob])
return ( return (
<PortalToFollowElem <PortalToFollowElem

View file

@ -56,7 +56,6 @@ const List = forwardRef<ListRef, ListProps>(({
useEffect(() => { useEffect(() => {
handleScroll() handleScroll()
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [list]) }, [list])
const handleHeadClick = () => { const handleHeadClick = () => {

View file

@ -122,7 +122,6 @@ const Tool: FC<Props> = ({
} }
if (!hasSearchText && !isFold) if (!hasSearchText && !isFold)
setFold(true) setFold(true)
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [hasSearchText]) }, [hasSearchText])
const FoldIcon = isFold ? RiArrowRightSLine : RiArrowDownSLine const FoldIcon = isFold ? RiArrowRightSLine : RiArrowDownSLine

View file

@ -40,7 +40,6 @@ const DatasetsDetailProvider: FC<DatasetsDetailProviderProps> = ({
}, []) }, [])
if (allDatasetIds.length === 0) return if (allDatasetIds.length === 0) return
updateDatasetsDetail(allDatasetIds) updateDatasetsDetail(allDatasetIds)
// eslint-disable-next-line react-hooks/exhaustive-deps
}, []) }, [])
return ( return (

View file

@ -22,7 +22,6 @@ export const HooksStoreContextProvider = ({ children, ...restProps }: HooksStore
useEffect(() => { useEffect(() => {
if (storeRef.current && d3Selection && d3Zoom) if (storeRef.current && d3Selection && d3Zoom)
storeRef.current.getState().refreshAll(restProps) storeRef.current.getState().refreshAll(restProps)
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [d3Selection, d3Zoom]) }, [d3Selection, d3Zoom])
if (!storeRef.current) if (!storeRef.current)

View file

@ -53,7 +53,6 @@ const Editor: FC<Props> = ({
useEffect(() => { useEffect(() => {
onFocusChange?.(isFocus) onFocusChange?.(isFocus)
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [isFocus]) }, [isFocus])
return ( return (

View file

@ -31,8 +31,6 @@ const useKeyValueList = (value: string, onChange: (value: string) => void, noFil
const newValue = list.filter(item => item.key && item.value).map(item => `${item.key}:${item.value}`).join('\n') const newValue = list.filter(item => item.key && item.value).map(item => `${item.key}:${item.value}`).join('\n')
if (newValue !== value) if (newValue !== value)
onChange(newValue) onChange(newValue)
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [list, noFilter]) }, [list, noFilter])
const addItem = useCallback(() => { const addItem = useCallback(() => {
setList([...list, { setList([...list, {

View file

@ -51,7 +51,6 @@ const useConfig = (id: string, payload: HttpNodeType) => {
setInputs(newInputs) setInputs(newInputs)
setIsDataReady(true) setIsDataReady(true)
} }
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [defaultConfig]) }, [defaultConfig])
const handleMethodChange = useCallback((method: Method) => { const handleMethodChange = useCallback((method: Method) => {

View file

@ -31,7 +31,6 @@ const MetadataTrigger = ({
handleRemoveCondition(condition.id) handleRemoveCondition(condition.id)
}) })
} }
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [metadataList, handleRemoveCondition, selectedDatasetsLoaded]) }, [metadataList, handleRemoveCondition, selectedDatasetsLoaded])
return ( return (

View file

@ -172,7 +172,6 @@ const useConfig = (id: string, payload: KnowledgeRetrievalNodeType) => {
} }
}) })
setInputs(newInput) setInputs(newInput)
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [currentProvider?.provider, currentModel, currentRerankModel, rerankDefaultModel]) }, [currentProvider?.provider, currentModel, currentRerankModel, rerankDefaultModel])
const [selectedDatasets, setSelectedDatasets] = useState<DataSet[]>([]) const [selectedDatasets, setSelectedDatasets] = useState<DataSet[]>([])
const [rerankModelOpen, setRerankModelOpen] = useState(false) const [rerankModelOpen, setRerankModelOpen] = useState(false)
@ -229,7 +228,6 @@ const useConfig = (id: string, payload: KnowledgeRetrievalNodeType) => {
setInputs(newInputs) setInputs(newInputs)
setSelectedDatasetsLoaded(true) setSelectedDatasetsLoaded(true)
})() })()
// eslint-disable-next-line react-hooks/exhaustive-deps
}, []) }, [])
useEffect(() => { useEffect(() => {
@ -241,7 +239,6 @@ const useConfig = (id: string, payload: KnowledgeRetrievalNodeType) => {
setInputs(produce(inputs, (draft) => { setInputs(produce(inputs, (draft) => {
draft.query_variable_selector = query_variable_selector draft.query_variable_selector = query_variable_selector
})) }))
// eslint-disable-next-line react-hooks/exhaustive-deps
}, []) }, [])
const handleOnDatasetsChange = useCallback((newDatasets: DataSet[]) => { const handleOnDatasetsChange = useCallback((newDatasets: DataSet[]) => {

View file

@ -34,7 +34,6 @@ const JsonImporter: FC<JsonImporterProps> = ({
const rect = importBtnRef.current.getBoundingClientRect() const rect = importBtnRef.current.getBoundingClientRect()
updateBtnWidth(rect.width) updateBtnWidth(rect.width)
} }
// eslint-disable-next-line react-hooks/exhaustive-deps
}, []) }, [])
const handleTrigger = useCallback((e: React.MouseEvent<HTMLElement, MouseEvent>) => { const handleTrigger = useCallback((e: React.MouseEvent<HTMLElement, MouseEvent>) => {

View file

@ -155,7 +155,6 @@ const useConfig = (id: string, payload: ParameterExtractorNodeType) => {
return return
setModelChanged(false) setModelChanged(false)
handleVisionConfigAfterModelChanged() handleVisionConfigAfterModelChanged()
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [isVisionModel, modelChanged]) }, [isVisionModel, modelChanged])
const { const {

View file

@ -88,7 +88,6 @@ const useConfig = (id: string, payload: QuestionClassifierNodeType) => {
return return
setModelChanged(false) setModelChanged(false)
handleVisionConfigAfterModelChanged() handleVisionConfigAfterModelChanged()
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [isVisionModel, modelChanged]) }, [isVisionModel, modelChanged])
const handleQueryVarChange = useCallback((newVar: ValueSelector | string) => { const handleQueryVarChange = useCallback((newVar: ValueSelector | string) => {
@ -110,7 +109,6 @@ const useConfig = (id: string, payload: QuestionClassifierNodeType) => {
query_variable_selector: inputs.query_variable_selector.length > 0 ? inputs.query_variable_selector : query_variable_selector, query_variable_selector: inputs.query_variable_selector.length > 0 ? inputs.query_variable_selector : query_variable_selector,
}) })
} }
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [defaultConfig]) }, [defaultConfig])
const handleClassesChange = useCallback((newClasses: any) => { const handleClassesChange = useCallback((newClasses: any) => {

View file

@ -140,7 +140,6 @@ const useConfig = (id: string, payload: ToolNodeType) => {
return return
const inputsWithDefaultValue = formattingParameters() const inputsWithDefaultValue = formattingParameters()
setInputs(inputsWithDefaultValue) setInputs(inputsWithDefaultValue)
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [currTool]) }, [currTool])
// setting when call // setting when call

View file

@ -193,11 +193,17 @@ export default combine(
'node/prefer-global/process': 'off', 'node/prefer-global/process': 'off',
'node/prefer-global/buffer': 'off', 'node/prefer-global/buffer': 'off',
'node/no-callback-literal': 'off', 'node/no-callback-literal': 'off',
'eslint-comments/no-unused-disable': 'off',
'tailwindcss/no-arbitrary-value': 'off',
'tailwindcss/classnames-order': 'off',
'style/indent': ['error', 2, {
SwitchCase: 1,
ignoreComments: true,
}],
// useful, but big change // useful, but big change
'unicorn/prefer-number-properties': 'warn', 'unicorn/prefer-number-properties': 'warn',
'unicorn/no-new-array': 'warn', 'unicorn/no-new-array': 'warn',
'style/indent': 'off',
}, },
}, },
// suppress error for `no-undef` rule // suppress error for `no-undef` rule

View file

@ -26,6 +26,7 @@
"lint": "npx oxlint && pnpm eslint --cache --cache-location node_modules/.cache/eslint/.eslint-cache", "lint": "npx oxlint && pnpm eslint --cache --cache-location node_modules/.cache/eslint/.eslint-cache",
"lint-only-show-error": "npm oxlint && pnpm eslint --cache --cache-location node_modules/.cache/eslint/.eslint-cache --quiet", "lint-only-show-error": "npm oxlint && pnpm eslint --cache --cache-location node_modules/.cache/eslint/.eslint-cache --quiet",
"fix": "eslint --fix .", "fix": "eslint --fix .",
"eslint": "eslint --cache --cache-location node_modules/.cache/eslint/.eslint-cache",
"eslint-fix": "eslint --cache --cache-location node_modules/.cache/eslint/.eslint-cache --fix", "eslint-fix": "eslint --cache --cache-location node_modules/.cache/eslint/.eslint-cache --fix",
"eslint-fix-only-show-error": "eslint --cache --cache-location node_modules/.cache/eslint/.eslint-cache --fix --quiet", "eslint-fix-only-show-error": "eslint --cache --cache-location node_modules/.cache/eslint/.eslint-cache --fix --quiet",
"eslint-complexity": "eslint --rule 'complexity: [error, {max: 15}]' --quiet", "eslint-complexity": "eslint --rule 'complexity: [error, {max: 15}]' --quiet",