chore(web): new lint setup (#30020)

Co-authored-by: yyh <yuanyouhuilyz@gmail.com>
This commit is contained in:
Stephen Zhou
2025-12-23 16:58:55 +08:00
committed by GitHub
parent 9701a2994b
commit f2842da397
3356 changed files with 85046 additions and 81278 deletions

View File

@ -1,5 +1,5 @@
import React from 'react'
import { act, render, screen, waitFor } from '@testing-library/react'
import React from 'react'
import CSVReader from './index'
let mockAcceptedFile: { name: string } | null = null
@ -28,7 +28,7 @@ describe('CSVReader', () => {
vi.clearAllMocks()
})
test('should display upload instructions when no file selected', async () => {
it('should display upload instructions when no file selected', async () => {
const onParsed = vi.fn()
render(<CSVReader onParsed={onParsed} />)
@ -41,7 +41,7 @@ describe('CSVReader', () => {
expect(onParsed).toHaveBeenCalledWith([['row1']])
})
test('should show accepted file name without extension', () => {
it('should show accepted file name without extension', () => {
mockAcceptedFile = { name: 'batch.csv' }
render(<CSVReader onParsed={vi.fn()} />)
@ -49,7 +49,7 @@ describe('CSVReader', () => {
expect(screen.getByText('.csv')).toBeInTheDocument()
})
test('should toggle hover styling on drag events', async () => {
it('should toggle hover styling on drag events', async () => {
render(<CSVReader onParsed={vi.fn()} />)
const dragEvent = { preventDefault: vi.fn() } as unknown as DragEvent

View File

@ -1,12 +1,12 @@
'use client'
import type { FC } from 'react'
import React, { useState } from 'react'
import { useTranslation } from 'react-i18next'
import {
useCSVReader,
} from 'react-papaparse'
import { useTranslation } from 'react-i18next'
import { cn } from '@/utils/classnames'
import { Csv as CSVIcon } from '@/app/components/base/icons/src/public/files'
import { cn } from '@/utils/classnames'
export type Props = {
onParsed: (data: string[][]) => void
@ -49,20 +49,24 @@ const CSVReader: FC<Props> = ({
{
acceptedFile
? (
<div className='flex w-full items-center space-x-2'>
<CSVIcon className="shrink-0" />
<div className='flex w-0 grow'>
<span className='max-w-[calc(100%_-_30px)] truncate text-text-secondary'>{acceptedFile.name.replace(/.csv$/, '')}</span>
<span className='shrink-0 text-text-tertiary'>.csv</span>
<div className="flex w-full items-center space-x-2">
<CSVIcon className="shrink-0" />
<div className="flex w-0 grow">
<span className="max-w-[calc(100%_-_30px)] truncate text-text-secondary">{acceptedFile.name.replace(/.csv$/, '')}</span>
<span className="shrink-0 text-text-tertiary">.csv</span>
</div>
</div>
</div>
)
)
: (
<div className='flex w-full items-center justify-center space-x-2'>
<CSVIcon className="shrink-0" />
<div className='text-text-tertiary'>{t('share.generation.csvUploadTitle')}<span className='cursor-pointer text-text-accent'>{t('share.generation.browse')}</span></div>
</div>
)}
<div className="flex w-full items-center justify-center space-x-2">
<CSVIcon className="shrink-0" />
<div className="text-text-tertiary">
{t('share.generation.csvUploadTitle')}
<span className="cursor-pointer text-text-accent">{t('share.generation.browse')}</span>
</div>
</div>
)
}
</div>
</>
)}