mirror of
https://github.com/infiniflow/ragflow.git
synced 2026-07-06 03:18:36 +08:00
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:
@@ -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,
|
||||
});
|
||||
|
||||
@@ -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) => {
|
||||
|
||||
@@ -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]);
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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(() => {
|
||||
|
||||
@@ -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 }],
|
||||
};
|
||||
|
||||
@@ -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),
|
||||
};
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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 &&
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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),
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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(() => {
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -62,7 +62,7 @@ const DataflowResult = () => {
|
||||
navigateToAgents,
|
||||
navigateToAgent,
|
||||
} = useNavigatePage();
|
||||
let fileUrl = useGetDocumentUrl(isAgent);
|
||||
const fileUrl = useGetDocumentUrl(isAgent);
|
||||
|
||||
const { highlights, setWidthAndHeight } =
|
||||
useGetChunkHighlights(selectedChunk);
|
||||
|
||||
@@ -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(() => {
|
||||
|
||||
@@ -12,7 +12,7 @@ export const useFetchMemoryBaseConfiguration = () => {
|
||||
const { handleInputChange, searchString, pagination, setPagination } =
|
||||
useHandleSearchChange();
|
||||
|
||||
let queryKey: (MemoryApiAction | number)[] = [
|
||||
const queryKey: (MemoryApiAction | number)[] = [
|
||||
MemoryApiAction.FetchMemoryDetail,
|
||||
];
|
||||
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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 (
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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';
|
||||
|
||||
@@ -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];
|
||||
|
||||
Reference in New Issue
Block a user