feat: migrate ESLint to v9 flat config

- Replace .eslintrc.json with eslint.config.mjs
- Simplify configuration using @antfu/eslint-config
- Add necessary ESLint plugin dependencies
- Disable overly strict style rules
- Set package.json type to module for ESM support
- Fix ESLint disable comment format

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
lyzno1
2025-09-10 22:21:17 +08:00
parent 2b1882a5e3
commit 05dcfcf0ca
85 changed files with 464 additions and 502 deletions

View File

@ -4,8 +4,7 @@
* @example formatNumber(1234567.89) will return '1,234,567.89'
*/
export const formatNumber = (num: number | string) => {
if (!num)
return num
if (!num) { return num }
const parts = num.toString().split('.')
parts[0] = parts[0].replace(/\B(?=(\d{3})+(?!\d))/g, ',')
return parts.join('.')
@ -18,8 +17,7 @@ export const formatNumber = (num: number | string) => {
* @example formatFileSize(1024 * 1024) will return '1.00MB'
*/
export const formatFileSize = (fileSize: number) => {
if (!fileSize)
return fileSize
if (!fileSize) { return fileSize }
const units = ['', 'K', 'M', 'G', 'T', 'P']
let index = 0
while (fileSize >= 1024 && index < units.length) {
@ -35,8 +33,7 @@ export const formatFileSize = (fileSize: number) => {
* @example formatTime(60 * 60) will return '1.00 h'
*/
export const formatTime = (seconds: number) => {
if (!seconds)
return seconds
if (!seconds) { return seconds }
const units = ['sec', 'min', 'h']
let index = 0
while (seconds >= 60 && index < units.length) {
@ -46,7 +43,7 @@ export const formatTime = (seconds: number) => {
return `${seconds.toFixed(2)} ${units[index]}`
}
export const downloadFile = ({ data, fileName }: { data: Blob; fileName: string }) => {
export const downloadFile = ({ data, fileName }: { data: Blob, fileName: string }) => {
const url = window.URL.createObjectURL(data)
const a = document.createElement('a')
a.href = url

View File

@ -3,8 +3,7 @@ import type { PromptVariable, UserInputFormItem } from '@/types/app'
export function replaceVarWithValues(str: string, promptVariables: PromptVariable[], inputs: Record<string, any>) {
return str.replace(/\{\{([^}]+)\}\}/g, (match, key) => {
const name = inputs[key]
if (name)
return name
if (name) { return name }
const valueObj: PromptVariable | undefined = promptVariables.find(v => v.key === key)
return valueObj ? `{{${valueObj.key}}}` : match
@ -12,8 +11,7 @@ export function replaceVarWithValues(str: string, promptVariables: PromptVariabl
}
export const userInputsFormToPromptVariables = (useInputs: UserInputFormItem[] | null) => {
if (!useInputs)
return []
if (!useInputs) { return [] }
const promptVariables: PromptVariable[] = []
useInputs.forEach((item: any) => {
const [type, content] = (() => {

View File

@ -1,6 +1,6 @@
const chars = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ-_'
export function randomString(length: number) {
let result = ''
for (let i = length; i > 0; --i) result += chars[Math.floor(Math.random() * chars.length)]
for (let i = length; i > 0; --i) { result += chars[Math.floor(Math.random() * chars.length)] }
return result
}

View File

@ -2,18 +2,15 @@ import type { ThoughtItem } from '@/app/components/chat/type'
import type { VisionFile } from '@/types/app'
export const sortAgentSorts = (list: ThoughtItem[]) => {
if (!list)
return list
if (list.some(item => item.position === undefined))
return list
if (!list) { return list }
if (list.some(item => item.position === undefined)) { return list }
const temp = [...list]
temp.sort((a, b) => a.position - b.position)
return temp
}
export const addFileInfos = (list: ThoughtItem[], messageFiles: VisionFile[]) => {
if (!list || !messageFiles)
return list
if (!list || !messageFiles) { return list }
return list.map((item) => {
if (item.files && item.files?.length > 0) {
return {