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
parent 414ee51975
commit 208ce4e774
118 changed files with 457 additions and 489 deletions

View File

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

View File

@@ -46,7 +46,7 @@ const ICON_MAP = {
dataset: <AppIcon innerIcon={DatasetSvg} className='!border-[0.5px] !border-indigo-100 !bg-indigo-25' />,
webapp: <div className='rounded-lg border-[0.5px] border-divider-subtle bg-util-colors-blue-brand-blue-brand-500 p-1 shadow-md'>
<WindowCursor className='h-4 w-4 text-text-primary-on-surface' />
</div>,
</div>,
notion: <AppIcon innerIcon={NotionSvg} className='!border-[0.5px] !border-indigo-100 !bg-white' />,
}

View File

@@ -67,7 +67,7 @@ const AppDetailNav = ({ title, desc, isExternal, icon, icon_background, navigati
<AppSidebarDropdown navigation={navigation} />
</div>
)
}
}
return (
<div

View File

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

View File

@@ -24,7 +24,7 @@ const DemoForm = () => {
},
})
const name = useStore(form.store, state => state.values.name)
const name = useStore(form.store, state => state.values.name)
return (
<form

View File

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

View File

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

View File

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

View File

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

View File

@@ -69,13 +69,13 @@ const ChunkDetailModal: FC<Props> = ({
<div>
<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={cn('body-md-regular text-text-secondary line-clamp-20')}>
<div className={cn('body-md-regular line-clamp-20 text-text-secondary')}>
{content}
</div>
</div>
<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={cn('body-md-regular text-text-secondary line-clamp-20')}>
<div className={cn('body-md-regular line-clamp-20 text-text-secondary')}>
{answer}
</div>
</div>

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -168,7 +168,7 @@ const getVarKindType = (type: FormTypeEnum) => {
return VarKindType.constant
if (type === FormTypeEnum.textInput || type === FormTypeEnum.secretInput)
return VarKindType.mixed
}
}
export const generateAgentToolValue = (value: Record<string, any>, formSchemas: { variable: string; default?: any; type: string }[], isReasoning = false) => {
const newValues = {} as any

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -37,7 +37,7 @@ const useNodesAvailableVarList = (nodes: Node[], {
}: Params = {
onlyLeafNodeVar: false,
filterVar: () => true,
}) => {
}) => {
const { getTreeLeafNodes, getBeforeNodesInSameBranchIncludeParent } = useWorkflow()
const { getNodeAvailableVars } = useWorkflowVariables()
const isChatMode = useIsChatMode()

View File

@@ -53,7 +53,6 @@ const Editor: FC<Props> = ({
useEffect(() => {
onFocusChange?.(isFocus)
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [isFocus])
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')
if (newValue !== value)
onChange(newValue)
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [list, noFilter])
const addItem = useCallback(() => {
setList([...list, {

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -88,7 +88,6 @@ const useConfig = (id: string, payload: QuestionClassifierNodeType) => {
return
setModelChanged(false)
handleVisionConfigAfterModelChanged()
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [isVisionModel, modelChanged])
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,
})
}
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [defaultConfig])
const handleClassesChange = useCallback((newClasses: any) => {

View File

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

View File

@@ -193,11 +193,17 @@ export default combine(
'node/prefer-global/process': 'off',
'node/prefer-global/buffer': '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
'unicorn/prefer-number-properties': 'warn',
'unicorn/no-new-array': 'warn',
'style/indent': 'off',
},
},
// 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-only-show-error": "npm oxlint && pnpm eslint --cache --cache-location node_modules/.cache/eslint/.eslint-cache --quiet",
"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-only-show-error": "eslint --cache --cache-location node_modules/.cache/eslint/.eslint-cache --fix --quiet",
"eslint-complexity": "eslint --rule 'complexity: [error, {max: 15}]' --quiet",