Fix: Error message: Use 'const' instead. (#13982)

### What problem does this PR solve?

Fix: Linter error message: Use 'const' instead.

### Type of change

- [x] Bug Fix (non-breaking change which fixes an issue)



<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->

## Summary by CodeRabbit

* **Refactor**
* Updated variable declarations across form components, agent utilities,
memory management hooks, and data handling functions to enhance code
consistency and maintainability throughout the application codebase.

* **Style**
* Added ESLint suppressions to document intentional constant-condition
patterns in asynchronous event streaming operations.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->
This commit is contained in:
balibabu
2026-04-08 18:13:14 +08:00
committed by GitHub
parent 3064895bbb
commit c0c3287af4
25 changed files with 30 additions and 28 deletions

View File

@@ -35,7 +35,7 @@ export const PptPreviewer: React.FC<PptPreviewerProps> = ({
width = containerRef.current.clientWidth - 50;
height = containerRef.current.clientHeight - 50;
}
let pptxPrviewer = init(containerRef.current, {
const pptxPrviewer = init(containerRef.current, {
width: width,
height: height,
});

View File

@@ -956,7 +956,7 @@ const DynamicForm = {
onClick={() => {
(async () => {
try {
let beValid = await form.trigger();
const beValid = await form.trigger();
console.log('form valid', beValid, form);
// if (beValid) {
// form.handleSubmit(async (values) => {

View File

@@ -64,7 +64,7 @@ const FloatingChatWidgetMarkdown = ({
const isDarkTheme = useIsDarkTheme();
const contentWithCursor = useMemo(() => {
let text = content === '' ? t('chat.searching') : content;
const text = content === '' ? t('chat.searching') : content;
const nextText = replaceTextByOldReg(text);
return pipe(replaceThinkToSection, preprocessLaTeX)(nextText);
}, [content, t]);

View File

@@ -259,6 +259,7 @@ export const useSendMessageWithSse = () => {
.pipeThrough(new EventSourceParserStream())
.getReader();
// eslint-disable-next-line no-constant-condition
while (true) {
try {
const x = await reader?.read();

View File

@@ -130,6 +130,7 @@ export const useSendMessageBySSE = (url: string) => {
.pipeThrough(new EventSourceParserStream())
.getReader();
// eslint-disable-next-line no-constant-condition
while (true) {
try {
const x = await reader?.read();

View File

@@ -166,7 +166,7 @@ export function PipelineAccordionOperators({
const { getOperatorTypeFromId } = useGraphStore((state) => state);
const operators = useMemo(() => {
let list = [
const list = [
...restrictSingleOperatorOnCanvas([Operator.Parser, Operator.Tokenizer]),
];
list.push(Operator.Extractor);

View File

@@ -10,7 +10,7 @@ export function useWatchFormChange(id?: string, form?: UseFormReturn<any>) {
// Manually triggered form updates are synchronized to the canvas
if (id) {
values = form?.getValues() || {};
let nextValues: any = values;
const nextValues: any = values;
updateNodeForm(id, nextValues);
}
@@ -18,7 +18,7 @@ export function useWatchFormChange(id?: string, form?: UseFormReturn<any>) {
}
export function useWatchNameFormChange(id?: string, form?: UseFormReturn<any>) {
let values = useWatch({ control: form?.control });
const values = useWatch({ control: form?.control });
const updateNodeName = useGraphStore((state) => state.updateNodeName);
useEffect(() => {

View File

@@ -11,7 +11,7 @@ export function useWatchFormChange(id?: string, form?: UseFormReturn<any>) {
// Manually triggered form updates are synchronized to the canvas
if (id && form?.formState.isDirty) {
values = form?.getValues();
let nextValues: any = {
const nextValues: any = {
...values,
prompts: [{ role: PromptRole.User, content: values.prompts }],
};

View File

@@ -19,7 +19,7 @@ export function useWatchFormChange(id?: string, form?: UseFormReturn) {
if (id && form?.formState.isDirty) {
values = form?.getValues();
console.log('🚀 ~ useEffect ~ values:', values);
let nextValues: any = {
const nextValues: any = {
...values,
outputs: transferToObject(values.outputs),
};

View File

@@ -12,12 +12,12 @@ export function useWatchFormChange(
id?: string,
form?: UseFormReturn<LoopFormSchemaType>,
) {
let values = useWatch({ control: form?.control });
const values = useWatch({ control: form?.control });
const { replaceNodeForm } = useGraphStore((state) => state);
useEffect(() => {
if (id) {
let nextValues = {
const nextValues = {
...values,
outputs: values.loop_variables?.reduce((pre, cur) => {
const variable = cur.variable;

View File

@@ -11,7 +11,7 @@ export function useWatchFormChange(id?: string, form?: UseFormReturn<any>) {
// Manually triggered form updates are synchronized to the canvas
if (id && form?.formState.isDirty) {
values = form?.getValues();
let nextValues: any = values;
const nextValues: any = values;
if (
values.delimiters !== undefined &&

View File

@@ -12,7 +12,7 @@ export function useWatchFormChange(id?: string, form?: UseFormReturn) {
console.log('🚀 ~ useWatchFormChange ~ values:', form?.formState.isDirty);
if (id) {
values = form?.getValues() || {};
let nextValues: any = {
const nextValues: any = {
...values,
conditions:
values?.conditions?.map((x: ISwitchCondition) => ({ ...x })) ?? [], // Changing the form value with useFieldArray does not change the array reference

View File

@@ -11,7 +11,7 @@ export function useWatchFormChange(id?: string, form?: UseFormReturn<any>) {
// Manually triggered form updates are synchronized to the canvas
if (id) {
values = form?.getValues();
let nextValues: any = {
const nextValues: any = {
...values,
include_domains: convertToStringArray(values.include_domains),
exclude_domains: convertToStringArray(values.exclude_domains),

View File

@@ -3,7 +3,7 @@ import { UseFormReturn, useWatch } from 'react-hook-form';
import useGraphStore from '../../store';
export function useWatchFormChange(form?: UseFormReturn<any>) {
let values = useWatch({ control: form?.control });
const values = useWatch({ control: form?.control });
const {
clickedToolId,

View File

@@ -7,7 +7,7 @@ export function useWatchFormChange(
id?: string,
form?: UseFormReturn<VariableAggregatorFormSchemaType>,
) {
let values = useWatch({ control: form?.control });
const values = useWatch({ control: form?.control });
const { replaceNodeForm } = useGraphStore((state) => state);
useEffect(() => {

View File

@@ -14,7 +14,7 @@ export function useWatchFormChange(
// Manually triggered form updates are synchronized to the canvas
if (id) {
values = form?.getValues() || {};
let nextValues: any = values;
const nextValues: any = values;
(enableReplacement ? replaceNodeForm : updateNodeForm)(id, nextValues);
}

View File

@@ -49,7 +49,7 @@ const WebhookSheet = ({ hideModal }: RunSheetProps) => {
return { status: 'running' };
}
let errorItem = data?.events.find(
const errorItem = data?.events.find(
(x) => x.event === 'error' || x.data?.error,
);
if (errorItem) {

View File

@@ -62,7 +62,7 @@ const DataflowResult = () => {
navigateToAgents,
navigateToAgent,
} = useNavigatePage();
let fileUrl = useGetDocumentUrl(isAgent);
const fileUrl = useGetDocumentUrl(isAgent);
const { highlights, setWidthAndHeight } =
useGetChunkHighlights(selectedChunk);

View File

@@ -5,7 +5,7 @@ import { useCallback, useEffect, useMemo, useRef } from 'react';
export function TagWordCloud() {
const domRef = useRef<HTMLDivElement>(null);
let chartRef = useRef<Chart>();
const chartRef = useRef<Chart>();
const { list } = useFetchTagList();
const { list: tagList } = useMemo(() => {

View File

@@ -12,7 +12,7 @@ export const useFetchMemoryBaseConfiguration = () => {
const { handleInputChange, searchString, pagination, setPagination } =
useHandleSearchChange();
let queryKey: (MemoryApiAction | number)[] = [
const queryKey: (MemoryApiAction | number)[] = [
MemoryApiAction.FetchMemoryDetail,
];

View File

@@ -22,7 +22,7 @@ export const useFetchMemoryMessageList = () => {
const { handleInputChange, searchString, pagination, setPagination } =
useHandleSearchChange();
const { filterValue, handleFilterSubmit } = useHandleFilterSubmit();
let queryKey: (MemoryApiAction | number)[] = [
const queryKey: (MemoryApiAction | number)[] = [
MemoryApiAction.FetchMemoryMessage,
];
const agentIds = Array.isArray(filterValue.agentId)

View File

@@ -215,7 +215,7 @@ const MarkdownContent = ({
const renderReference = useCallback(
(text: string) => {
let replacedText = reactStringReplace(text, currentReg, (match) => {
const replacedText = reactStringReplace(text, currentReg, (match) => {
const chunkIndex = getChunkIndex(match);
return (

View File

@@ -46,7 +46,7 @@ export const useListDataSource = () => {
const updatedDataSourceTemplates = useMemo(() => {
const categorizedData = categorizeDataBySource(list || []);
let sourceList: Array<IDataSorceInfo & { list: Array<IDataSourceBase> }> =
const sourceList: Array<IDataSorceInfo & { list: Array<IDataSourceBase> }> =
[];
Object.keys(categorizedData).forEach((key: string) => {
const k = key as DataSourceKey;

View File

@@ -54,10 +54,10 @@ export const transformBase64ToFile = (
dataUrl: string,
filename: string = 'file',
) => {
let arr = dataUrl.split(','),
bstr = atob(arr[1]),
n = bstr.length,
u8arr = new Uint8Array(n);
const arr = dataUrl.split(','),
bstr = atob(arr[1]);
let n = bstr.length;
const u8arr = new Uint8Array(n);
const mime = arr[0].match(/:(.*?);/);
const mimeType = mime ? mime[1] : 'image/png';

View File

@@ -17,7 +17,7 @@ const registerServer = <T extends string>(
request: RequestMethod,
) => {
const server: Service<T> = {} as Service<T>;
for (let key in opt) {
for (const key in opt) {
server[key] = (params?: any, urlAppendix?: string) => {
let url = opt[key].url;
const requestOptions = opt[key];