Skip to content

Commit

Permalink
chore: update lint tool
Browse files Browse the repository at this point in the history
  • Loading branch information
谨欣 committed Aug 29, 2024
1 parent 47777da commit 2f37a1f
Show file tree
Hide file tree
Showing 190 changed files with 4,007 additions and 3,528 deletions.
3 changes: 3 additions & 0 deletions web/.eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
node_modules/
build/
dist/
57 changes: 57 additions & 0 deletions web/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
module.exports = {
env: {
browser: true,
es2021: true,
node: true,
commonjs: true,
},
extends: [
'eslint:recommended',
'plugin:@typescript-eslint/recommended',
'plugin:react/recommended',
'plugin:react-hooks/recommended',
'plugin:prettier/recommended',
'prettier',
],
parser: '@typescript-eslint/parser',
parserOptions: {
ecmaFeatures: {
jsx: true,
},
ecmaVersion: 12,
sourceType: 'module',
},
plugins: ['@typescript-eslint', 'prettier'],
rules: {
'prettier/prettier': 'error',
'react/react-in-jsx-scope': 'off',
'react/prop-types': 'off',
'@typescript-eslint/no-explicit-any': 'off',
'@typescript-eslint/no-unused-expressions': ['error', { allowShortCircuit: true, allowTernary: true }],
'@typescript-eslint/no-unused-vars': [
'error',
{
args: 'all',
argsIgnorePattern: '^_',
caughtErrors: 'all',
caughtErrorsIgnorePattern: '^_',
destructuredArrayIgnorePattern: '^_',
varsIgnorePattern: '^_',
ignoreRestSiblings: true,
},
],
quotes: ['error', 'single', { allowTemplateLiterals: true, avoidEscape: true }],
semi: ['error', 'always'],
},
settings: {
react: {
version: 'detect',
},
'import/resolver': {
typescript: {
alwaysTryTypes: true,
project: './tsconfig.json',
},
},
},
};
3 changes: 3 additions & 0 deletions web/.prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
node_modules/
build/
dist/
16 changes: 16 additions & 0 deletions web/.prettierrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
module.exports = {
printWidth: 120,
tabWidth: 2,
useTabs: false,
semi: true,
singleQuote: true,
jsxSingleQuote: true,
trailingComma: "all",
bracketSpacing: true,
jsxBracketSameLine: false,
arrowParens: "avoid",
plugins: [
require.resolve('prettier-plugin-organize-imports'),
require.resolve('prettier-plugin-packagejson'),
]
}
10 changes: 5 additions & 5 deletions web/app/chat-context.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { apiInterceptors, getDialogueList, getUsableModels, queryAdminList } from '@/client/api';
import { apiInterceptors, getUsableModels, queryAdminList } from '@/client/api';
import { ChatHistoryResponse, DialogueListResponse, IChatDialogueSchema } from '@/types/chat';
import { UserInfoResponse } from '@/types/userinfo';
import { getUserId } from '@/utils';
import { STORAGE_THEME_KEY } from '@/utils/constants/index';
import { useRequest } from 'ahooks';
import { useSearchParams } from 'next/navigation';
import { createContext, useEffect, useMemo, useState } from 'react';
import { createContext, useEffect, useState } from 'react';

type ThemeMode = 'dark' | 'light';

Expand Down Expand Up @@ -109,7 +109,7 @@ const ChatContextProvider = ({ children }: { children: React.ReactElement }) =>
return res ?? [];
},
{
onSuccess: (data) => {
onSuccess: data => {
setAdminList(data);
},
manual: true,
Expand All @@ -120,15 +120,15 @@ const ChatContextProvider = ({ children }: { children: React.ReactElement }) =>
if (getUserId()) {
queryAdminListRun();
}
// eslint-disable-next-line react-hooks/exhaustive-deps
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [queryAdminListRun, getUserId()]);

useEffect(() => {
setMode(getDefaultTheme());
try {
const dialogInfo = JSON.parse(localStorage.getItem('cur_dialog_info') || '');
setCurrentDialogInfo(dialogInfo);
} catch (error) {
} catch {
setCurrentDialogInfo({
chat_scene: '',
app_code: '',
Expand Down
23 changes: 7 additions & 16 deletions web/client/api/flow/index.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import {
IFlow,
IFlowExportParams,
IFlowImportParams,
IFlowNode,
IFlowRefreshParams,
IFlowResponse,
IFlowUpdateParam,
IFlowRefreshParams,
IFlowExportParams,
IFlowImportParams,
IUploadFileRequestParams,
IUploadFileResponse,
} from '@/types/flow';
Expand All @@ -16,7 +16,7 @@ export const addFlow = (data: IFlowUpdateParam) => {
return POST<IFlowUpdateParam, IFlow>('/api/v2/serve/awel/flows', data);
};

export const getFlows = (page?: number, page_size?: number) => {
export const getFlows = ({ page, page_size }: { page?: number; page_size?: number }) => {
return GET<any, IFlowResponse>('/api/v2/serve/awel/flows', {
page,
page_size,
Expand All @@ -40,32 +40,23 @@ export const getFlowNodes = () => {
};

export const refreshFlowNodeById = (data: IFlowRefreshParams) => {
return POST<IFlowRefreshParams, IFlowNode>(
'/api/v2/serve/awel/nodes/refresh',
data
);
return POST<IFlowRefreshParams, IFlowNode>('/api/v2/serve/awel/nodes/refresh', data);
};

export const debugFlow = (data: any) => {
return POST<any, IFlowNode>('/api/v2/serve/awel/flow/debug', data);
};

export const exportFlow = (data: IFlowExportParams) => {
return GET<IFlowExportParams, any>(
`/api/v2/serve/awel/flow/export/${data.uid}`,
data
);
return GET<IFlowExportParams, any>(`/api/v2/serve/awel/flow/export/${data.uid}`, data);
};

export const importFlow = (data: IFlowImportParams) => {
return POST<IFlowImportParams, any>('/api/v2/serve/awel/flow/import', data);
};

export const uploadFile = (data: IUploadFileRequestParams) => {
return POST<IUploadFileRequestParams, Array<IUploadFileResponse>>(
'/api/v2/serve/file/files/dbgpt',
data
);
return POST<IUploadFileRequestParams, Array<IUploadFileResponse>>('/api/v2/serve/file/files/dbgpt', data);
};

export const downloadFile = (fileId: string) => {
Expand Down
Loading

0 comments on commit 2f37a1f

Please sign in to comment.