Compare commits

...

6 Commits

Author SHA1 Message Date
yyh
b60498b2a7 Merge branch 'main' into 4-17-lint-config-for-react 2026-04-21 15:25:36 +08:00
yyh
66c91604b1 tweaks 2026-04-19 13:00:56 +08:00
yyh
3aa578ceac Merge branch 'main' into 4-17-lint-config-for-react 2026-04-18 15:24:31 +08:00
1ccb763e24 tweaks 2026-04-18 00:26:37 +08:00
bcb6eb484f tweaks 2026-04-18 00:12:18 +08:00
4dae959c28 chore: lint dify ui with react config 2026-04-17 22:21:38 +08:00
5 changed files with 54 additions and 13 deletions

View File

@ -1,4 +1,9 @@
{
"e2e/cucumber.config.ts": {
"node/prefer-global/process": {
"count": 1
}
},
"e2e/features/support/hooks.ts": {
"no-console": {
"count": 3
@ -7,16 +12,47 @@
"count": 1
}
},
"e2e/fixtures/auth.ts": {
"node/prefer-global/process": {
"count": 5
}
},
"e2e/scripts/common.ts": {
"node/prefer-global/buffer": {
"count": 2
},
"node/prefer-global/process": {
"count": 8
}
},
"e2e/scripts/run-cucumber.ts": {
"node/prefer-global/process": {
"count": 9
}
},
"e2e/scripts/setup.ts": {
"node/prefer-global/process": {
"count": 4
}
},
"e2e/support/process.ts": {
"node/prefer-global/process": {
"count": 4
},
"ts/no-use-before-define": {
"count": 2
}
},
"e2e/test-env.ts": {
"node/prefer-global/process": {
"count": 7
}
},
"packages/dify-ui/vite.config.ts": {
"node/prefer-global/process": {
"count": 1
}
},
"packages/migrate-no-unchecked-indexed-access/src/no-unchecked-indexed-access/migrate.ts": {
"no-console": {
"count": 11

View File

@ -1,5 +1,3 @@
// @ts-check
import antfu, { GLOB_MARKDOWN } from '@antfu/eslint-config'
import md from 'eslint-markdown'
import markdownPreferences from 'eslint-plugin-markdown-preferences'
@ -17,6 +15,13 @@ export default antfu(
'!vite.config.ts',
...original,
],
react: {
files: ['packages/dify-ui/**/*.{ts,tsx}'],
overrides: {
'react/set-state-in-effect': 'error',
'react/no-unnecessary-use-prefix': 'error',
},
},
typescript: {
overrides: {
'ts/consistent-type-definitions': ['error', 'type'],
@ -35,7 +40,12 @@ export default antfu(
'antfu/top-level-function': 'off',
},
},
e18e: false,
},
{
files: ['packages/dify-ui/**/*.{ts,tsx}'],
rules: {
'react-refresh/only-export-components': 'off',
},
},
markdownPreferences.configs.standard,
{
@ -57,9 +67,4 @@ export default antfu(
'markdown-preferences/sort-definitions': 'error',
},
},
{
rules: {
'node/prefer-global/process': 'off',
},
},
)

View File

@ -137,7 +137,7 @@ describe('@langgenius/dify-ui/toast', () => {
await vi.advanceTimersByTimeAsync(4999)
expect(document.body).toHaveTextContent('Default timeout')
await vi.advanceTimersByTimeAsync(1)
await vi.advanceTimersByTimeAsync(10)
await vi.waitFor(() => {
expect(document.body).not.toHaveTextContent('Default timeout')
})
@ -152,7 +152,7 @@ describe('@langgenius/dify-ui/toast', () => {
await vi.advanceTimersByTimeAsync(2999)
expect(document.body).toHaveTextContent('Configured timeout')
await vi.advanceTimersByTimeAsync(1)
await vi.advanceTimersByTimeAsync(10)
await vi.waitFor(() => {
expect(document.body).not.toHaveTextContent('Configured timeout')
})
@ -166,7 +166,7 @@ describe('@langgenius/dify-ui/toast', () => {
})
await expect.element(screen.getByText('Custom timeout')).toBeInTheDocument()
await vi.advanceTimersByTimeAsync(1000)
await vi.advanceTimersByTimeAsync(1010)
await vi.waitFor(() => {
expect(document.body).not.toHaveTextContent('Custom timeout')
})

View File

@ -136,7 +136,7 @@ const StackExamples = () => {
const PromiseExamples = () => {
const createPromiseToast = () => {
const request = new Promise<string>((resolve) => {
window.setTimeout(() => resolve('The deployment is now available in production.'), 1400)
window.setTimeout(resolve, 1400, 'The deployment is now available in production.')
})
void toast.promise(request, {

View File

@ -81,7 +81,7 @@ type ToastApi = {
const toastManager = BaseToast.createToastManager<ToastData>()
function isToastType(type: string): type is ToastType {
return Object.prototype.hasOwnProperty.call(TOAST_TONE_STYLES, type)
return Object.hasOwn(TOAST_TONE_STYLES, type)
}
function getToastType(type?: string): ToastType | undefined {