From 39a7441a0f3518934263e34eea59184d5a46905b Mon Sep 17 00:00:00 2001
From: "deepsource-autofix[bot]"
<62050782+deepsource-autofix[bot]@users.noreply.github.com>
Date: Wed, 6 Nov 2024 10:44:08 +0000
Subject: [PATCH] style: format code with Prettier and StandardJS
This commit fixes the style issues introduced in 0cefe9a according to the output
from Prettier and StandardJS.
Details: None
---
eslint.config.mjs | 28 ++++++-------
.../hooks/usePollingEffect/index.js | 2 +-
src/components/hooks/useWebsocket/index.js | 4 +-
src/components/stateful/TreeList/utils.js | 34 ++++++++--------
src/pages/home/index.jsx | 40 +++++++++----------
src/service/useFetch.js | 12 +++---
src/utils/aidFn.js | 18 ++++-----
src/utils/previewScale/index.js | 4 +-
8 files changed, 72 insertions(+), 70 deletions(-)
diff --git a/eslint.config.mjs b/eslint.config.mjs
index db7eb3b1..1adaa813 100644
--- a/eslint.config.mjs
+++ b/eslint.config.mjs
@@ -15,12 +15,12 @@ const __dirname = path.dirname(__filename)
const compat = new FlatCompat({
baseDirectory: __dirname,
recommendedConfig: js.configs.recommended,
- allConfig: js.configs.all,
+ allConfig: js.configs.all
})
export default [
{
- ignores: ['node_modules/**/*', '**/CHANGELOG.md', '**/package-lock.json', 'dist/**/*', 'build/**/*', '**/coverage'],
+ ignores: ['node_modules/**/*', '**/CHANGELOG.md', '**/package-lock.json', 'dist/**/*', 'build/**/*', '**/coverage']
},
...compat.extends('plugin:react/recommended', 'prettier'),
{
@@ -28,12 +28,12 @@ export default [
react,
'@typescript-eslint': typescriptEslint,
'react-hooks': fixupPluginRules(reactHooks),
- prettier,
+ prettier
},
languageOptions: {
globals: {
- ...globals.browser,
+ ...globals.browser
},
parser: tsParser,
@@ -42,15 +42,15 @@ export default [
parserOptions: {
ecmaFeatures: {
- jsx: true,
- },
- },
+ jsx: true
+ }
+ }
},
settings: {
react: {
- version: 'detect',
- },
+ version: 'detect'
+ }
},
rules: {
@@ -61,8 +61,8 @@ export default [
'prettier/prettier': [
'error',
{
- endOfLine: 'auto',
- },
+ endOfLine: 'auto'
+ }
],
semi: 'off',
@@ -94,7 +94,7 @@ export default [
'no-inner-declarations': 'off',
'no-unused-expressions': 'off',
'no-unused-vars': 'off',
- 'no-plusplus': 'off',
- },
- },
+ 'no-plusplus': 'off'
+ }
+ }
]
diff --git a/src/components/hooks/usePollingEffect/index.js b/src/components/hooks/usePollingEffect/index.js
index 986e46ba..dd24698d 100644
--- a/src/components/hooks/usePollingEffect/index.js
+++ b/src/components/hooks/usePollingEffect/index.js
@@ -4,7 +4,7 @@ const usePollingEffect = (asyncCallback, dependencies = [], options = { interval
const timeoutIdRef = useRef(null)
useEffect(() => {
// Side note: preceding semicolon needed for IIFEs.
- ;(async function pollingCallback() {
+ ;(async function pollingCallback () {
try {
await asyncCallback()
} finally {
diff --git a/src/components/hooks/useWebsocket/index.js b/src/components/hooks/useWebsocket/index.js
index 15fd865b..c171d4ee 100644
--- a/src/components/hooks/useWebsocket/index.js
+++ b/src/components/hooks/useWebsocket/index.js
@@ -15,7 +15,7 @@ const useWebsocket = ({ url, verify }) => {
{ key: 0, value: '正在链接中' },
{ key: 1, value: '已经链接并且可以通讯' },
{ key: 2, value: '连接正在关闭' },
- { key: 3, value: '连接已关闭或者没有链接成功' },
+ { key: 3, value: '连接已关闭或者没有链接成功' }
]
try {
ws.current = new WebSocket(url)
@@ -70,7 +70,7 @@ const useWebsocket = ({ url, verify }) => {
wsData,
readyState,
closeWebSocket,
- reconnect,
+ reconnect
}
}
export default useWebsocket
diff --git a/src/components/stateful/TreeList/utils.js b/src/components/stateful/TreeList/utils.js
index 8286a8d4..33ff3623 100644
--- a/src/components/stateful/TreeList/utils.js
+++ b/src/components/stateful/TreeList/utils.js
@@ -1,9 +1,9 @@
import React from 'react'
-export function getDefaultKey(treeData) {
+export function getDefaultKey (treeData) {
let selected = []
let expanded = []
- function forFn(data, parentKey) {
+ function forFn (data, parentKey) {
return data.some((item) => {
if (item.children && item.children.length) {
return forFn(item.children, item.key)
@@ -17,14 +17,14 @@ export function getDefaultKey(treeData) {
return { selected, expanded }
}
-export function processTreeData(list, pid) {
+export function processTreeData (list, pid) {
return list
.filter((item) => item.pid === pid)
.map((item) => ({
pid,
key: item.id,
title: item.name,
- children: processTreeData(list, item.id),
+ children: processTreeData(list, item.id)
}))
}
@@ -36,16 +36,16 @@ export const loopTreeData = (data) =>
title,
key: item.key,
pid: item.pid,
- children: loopTreeData(item.children),
+ children: loopTreeData(item.children)
}
}
return {
title,
key: item.key,
- pid: item.pid,
+ pid: item.pid
}
})
-export function expandTree(a, b, setExpandedKeys) {
+export function expandTree (a, b, setExpandedKeys) {
if (b.expanded) {
if (a.length > 0) {
a.splice(0, a.length - 1)
@@ -75,27 +75,29 @@ export const loopTreeDataWithSearch = (data, searchValue) =>
const beforeStr = item.title.substr(0, index)
const afterStr = item.title.substr(index + searchValue.length)
const title =
- index > -1 ? (
-
- {beforeStr} {searchValue} {afterStr}
-
- ) : (
- {item.title}
- )
+ index > -1
+ ? (
+
+ {beforeStr} {searchValue} {afterStr}
+
+ )
+ : (
+ {item.title}
+ )
if (item.children) {
return {
title,
key: item.key,
pid: item.pid,
// selectable: item.flag,
- children: loopTreeDataWithSearch(item.children, searchValue),
+ children: loopTreeDataWithSearch(item.children, searchValue)
}
}
return {
title,
// selectable: item.flag,
key: item.key,
- pid: item.pid,
+ pid: item.pid
}
})
export const getParentKey = (key, tree) => {
diff --git a/src/pages/home/index.jsx b/src/pages/home/index.jsx
index 9ed77b24..d7cdc447 100644
--- a/src/pages/home/index.jsx
+++ b/src/pages/home/index.jsx
@@ -80,8 +80,8 @@ const Home = () => {
[
{
content: text,
- role: 'user',
- },
+ role: 'user'
+ }
],
key,
signal
@@ -168,22 +168,22 @@ const Home = () => {
I love coding in .
-
+
@@ -202,18 +202,18 @@ const Home = () => {
-
+
<>
-
+
>
@@ -229,26 +229,26 @@ const Home = () => {
mask
-
-
+
+
{/* */}
{
}
- type="primary"
+ type='primary'
disabled={isStream}
onClick={onSubmit}
>
发送
- } type="primary" disabled={!isStream} onClick={onStop}>
+ } type='primary' disabled={!isStream} onClick={onStop}>
停止
diff --git a/src/service/useFetch.js b/src/service/useFetch.js
index 2be3d962..56d6e58b 100644
--- a/src/service/useFetch.js
+++ b/src/service/useFetch.js
@@ -17,7 +17,7 @@ export const useReqFetch = (url, opts) => {
setLoading(true)
const resData = await reqFetch(url, {
...opts,
- controller,
+ controller
})
if (!canceled) {
setRes(resData)
@@ -48,29 +48,29 @@ export const useReqFetch = (url, opts) => {
export const usePostFetch = (url, opts) =>
useReqFetch(url, {
...opts,
- method: 'POST',
+ method: 'POST'
})
export const useGetFetch = (url, opts) =>
useReqFetch(url, {
...opts,
- method: 'GET',
+ method: 'GET'
})
export const usePutFetch = (url, opts) =>
useReqFetch(url, {
...opts,
- method: 'PUT',
+ method: 'PUT'
})
export const useDeleteFetch = (url, opts) =>
useReqFetch(url, {
...opts,
- method: 'DELETE',
+ method: 'DELETE'
})
export const usePatchFetch = (url, opts) =>
useReqFetch(url, {
...opts,
- method: 'PATCH',
+ method: 'PATCH'
})
diff --git a/src/utils/aidFn.js b/src/utils/aidFn.js
index efaf2e2c..7e98a13f 100644
--- a/src/utils/aidFn.js
+++ b/src/utils/aidFn.js
@@ -65,7 +65,7 @@ export const getImgsUrl = (html) => {
export const customizeTimer = {
intervalTimer: null,
timeoutTimer: null,
- setTimeout(cb, interval) {
+ setTimeout (cb, interval) {
const { now } = Date
const stime = now()
let etime = stime
@@ -80,10 +80,10 @@ export const customizeTimer = {
this.timeoutTimer = requestAnimationFrame(loop)
return this.timeoutTimer
},
- clearTimeout() {
+ clearTimeout () {
cancelAnimationFrame(this.timeoutTimer)
},
- setInterval(cb, interval) {
+ setInterval (cb, interval) {
const { now } = Date
let stime = now()
let etime = stime
@@ -99,9 +99,9 @@ export const customizeTimer = {
this.intervalTimer = requestAnimationFrame(loop)
return this.intervalTimer
},
- clearInterval() {
+ clearInterval () {
cancelAnimationFrame(this.intervalTimer)
- },
+ }
}
export const isDecimal = (value) => {
@@ -251,13 +251,13 @@ export const oneApiChat = (chatList, token, signal) =>
signal,
headers: {
Authorization: token,
- 'Content-Type': 'application/json',
+ 'Content-Type': 'application/json'
},
body: JSON.stringify({
model: 'gpt-3.5-turbo',
messages: chatList,
- stream: true,
- }),
+ stream: true
+ })
})
export const getCurrentDate = () => {
@@ -285,7 +285,7 @@ export const saveHtmlToPng = async (eleHtml, successFun, errorFun) => {
try {
const ele = eleHtml ?? document.getElementById('image-wrapper')
const canvas = await html2canvas(ele, {
- useCORS: true,
+ useCORS: true
})
const imgUrl = canvas.toDataURL('image/png')
const tempLink = document.createElement('a')
diff --git a/src/utils/previewScale/index.js b/src/utils/previewScale/index.js
index e1adc54b..85bc637c 100644
--- a/src/utils/previewScale/index.js
+++ b/src/utils/previewScale/index.js
@@ -8,7 +8,7 @@ const previewFitScale = (width, height, scaleDom, callback) => {
// * 默认缩放值
const scale = {
width: 1,
- height: 1,
+ height: 1
}
// * 需保持的比例
@@ -51,7 +51,7 @@ const previewFitScale = (width, height, scaleDom, callback) => {
return {
calcRate,
windowResize,
- unWindowResize,
+ unWindowResize
}
}