chore: fix oxlint warnings (unused variables and imports) (#35249)

Co-authored-by: Your Name <you@example.com>
Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-authored-by: Asuka Minato <i@asukaminato.eu.org>
This commit is contained in:
sicnuyudidi 2026-04-20 21:43:17 +08:00 committed by GitHub
parent df389eba1c
commit a633387e9b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
19 changed files with 31 additions and 31 deletions

View File

@ -43,7 +43,7 @@ vi.mock('../form-fields', () => ({
>
invalid-name-change
</button>
<button data-testid="valid-json-change" onClick={() => props.onJSONSchemaChange('{\n \"foo\": \"bar\"\n}')}>valid-json-change</button>
<button data-testid="valid-json-change" onClick={() => props.onJSONSchemaChange('{\n "foo": "bar"\n}')}>valid-json-change</button>
<button data-testid="empty-json-change" onClick={() => props.onJSONSchemaChange(' ')}>empty-json-change</button>
<button data-testid="invalid-json-change" onClick={() => props.onJSONSchemaChange('{invalid-json}')}>invalid-json-change</button>
<button data-testid="type-change" onClick={() => props.onTypeChange({ value: InputVarType.singleFile })}>type-change</button>

View File

@ -91,7 +91,7 @@ function buildDirectiveRehypePlugins(): PluggableList {
])
const attributes: Record<string, AttributeDefinition[]> = {
...(defaultSanitizeSchema.attributes ?? {}),
...defaultSanitizeSchema.attributes,
}
for (const [tagName, allowedAttributes] of Object.entries(DIRECTIVE_ALLOWED_TAGS))

View File

@ -86,7 +86,7 @@ function buildRehypePlugins(extraPlugins?: PluggableList): PluggableList {
])
const mergedAttributes: Record<string, AttributeDefinition[]> = {
...(defaultSanitizeSchema.attributes ?? {}),
...defaultSanitizeSchema.attributes,
}
for (const tag of Object.keys(ALLOWED_TAGS)) {

View File

@ -75,7 +75,7 @@ export function useMetadataState({ docDetail, onUpdate }: UseMetadataStateOption
setEditStatus(true)
}
const cancelEdit = () => {
setMetadataParams({ documentType: docType || '', metadata: { ...(docDetail?.doc_metadata || {}) } })
setMetadataParams({ documentType: docType || '', metadata: { ...docDetail?.doc_metadata } })
setEditStatus(!docType)
if (!docType)
setShowDocTypes(true)

View File

@ -47,7 +47,7 @@ vi.mock('@/app/components/base/input', () => ({
}))
vi.mock('@/app/components/base/portal-to-follow-elem', async () => {
const React = await import('react')
const _React = await import('react')
return {
PortalToFollowElem: ({ children }: { children: React.ReactNode }) => <div>{children}</div>,
PortalToFollowElemTrigger: ({

View File

@ -145,7 +145,7 @@ describe('LogViewer', () => {
})
it('should parse request data when it is raw JSON', () => {
const log = createLog({ request: { ...createLog().request, data: '{\"hello\":1}' } })
const log = createLog({ request: { ...createLog().request, data: '{"hello":1}' } })
render(<LogViewer logs={[log]} />)

View File

@ -67,7 +67,7 @@ vi.mock('@/app/components/plugins/plugin-detail-panel/model-selector', () => ({
vi.mock('@/app/components/workflow/nodes/_base/components/editor/code-editor', () => ({
default: ({ onChange }: { onChange: (value: string) => void }) => (
<button data-testid="code-editor" onClick={() => onChange('{\"foo\":\"bar\"}')}>
<button data-testid="code-editor" onClick={() => onChange('{"foo":"bar"}')}>
Update JSON
</button>
),

View File

@ -14,7 +14,7 @@ vi.mock('@langgenius/dify-ui/button', () => ({
}))
vi.mock('@/app/components/base/portal-to-follow-elem', async () => {
const React = await import('react')
const _React = await import('react')
return {
PortalToFollowElem: ({
open,

View File

@ -22,7 +22,7 @@ vi.mock('@/app/components/base/loading', () => ({
}))
vi.mock('@/app/components/base/portal-to-follow-elem', async () => {
const React = await import('react')
const _React = await import('react')
return {
PortalToFollowElem: ({
open,

View File

@ -501,7 +501,8 @@ describe('useWorkflowRun', () => {
windowWithDebugControllers.__allTriggersDebugAbortController = { abort: allTriggersAbort }
const refController = new AbortController()
const refAbortSpy = vi.spyOn(refController, 'abort')
const { getAbortController } = mocks.mockSsePost.mock.calls.at(-1)?.[2] as {
const lastCall = mocks.mockSsePost.mock.calls.at(-1)
const { getAbortController } = (lastCall?.[2] ?? {}) as {
getAbortController?: (controller: AbortController) => void
}
getAbortController?.(refController)

View File

@ -1543,7 +1543,7 @@ export const useNodesInteractions = () => {
targetHandle,
type: CUSTOM_EDGE,
data: {
...(edge.data || {}),
...edge.data,
sourceType: newCurrentNode.data.type,
targetType: targetNodeForEdge.data.type,
isInIteration,
@ -1583,7 +1583,7 @@ export const useNodesInteractions = () => {
targetHandle,
type: CUSTOM_EDGE,
data: {
...(edge.data || {}),
...edge.data,
sourceType: sourceNode.data.type,
targetType: newCurrentNode.data.type,
isInIteration: newNodeIsInIteration,

View File

@ -320,7 +320,7 @@ describe('assigner path', () => {
<VarList
readonly={false}
nodeId="node-1"
list={[createOperation({ operation: WriteMode.set, value: '{\"a\":1}' })]}
list={[createOperation({ operation: WriteMode.set, value: '{"a":1}' })]}
onChange={onChange}
filterVar={vi.fn(() => true)}
filterToAssignedVar={vi.fn(() => true)}
@ -332,9 +332,9 @@ describe('assigner path', () => {
/>,
)
fireEvent.change(screen.getByLabelText('code-editor'), { target: { value: '{\"a\":2}' } })
fireEvent.change(screen.getByLabelText('code-editor'), { target: { value: '{"a":2}' } })
expect(onChange).toHaveBeenLastCalledWith([
createOperation({ operation: WriteMode.set, value: '{\"a\":2}' }),
createOperation({ operation: WriteMode.set, value: '{"a":2}' }),
], '{"a":2}')
onChange.mockClear()

View File

@ -32,7 +32,7 @@ describe('curl-panel', () => {
describe('parseCurl', () => {
it('should parse method, headers, json body, and query params from a valid curl command', () => {
const { node, error } = curlParser.parseCurl('curl -X POST -H \"Authorization: Bearer token\" --json \"{\"name\":\"openai\"}\" https://example.com/users?page=1&size=2')
const { node, error } = curlParser.parseCurl('curl -X POST -H "Authorization: Bearer token" --json "{"name":"openai"}" https://example.com/users?page=1&size=2')
expect(error).toBeNull()
expect(node).toMatchObject({

View File

@ -563,7 +563,7 @@ describe('loop path', () => {
id: 'loop-var-object',
var_type: VarType.arrayObject,
value_type: ValueType.constant,
value: '[{\"id\":1}]',
value: '[{"id":1}]',
})}
onChange={onObjectChange}
/>
@ -571,7 +571,7 @@ describe('loop path', () => {
)
fireEvent.change(screen.getByDisplayValue('draft'), { target: { value: 'published' } })
fireEvent.change(screen.getByLabelText('code-editor'), { target: { value: '[{\"id\":2}]' } })
fireEvent.change(screen.getByLabelText('code-editor'), { target: { value: '[{"id":2}]' } })
expect(onStringChange).toHaveBeenCalledWith('published')
expect(onObjectChange).toHaveBeenCalledWith('[{"id":2}]')

View File

@ -122,7 +122,7 @@ export const ModalContextProvider = ({
const setShowAccountSettingModal = useCallback((next: SetStateAction<ModalState<AccountSettingTab> | null>) => {
const currentState = accountSettingTab
? { payload: accountSettingTab, ...(accountSettingCallbacksRef.current ?? {}) }
? { payload: accountSettingTab, ...accountSettingCallbacksRef.current }
: null
const resolvedState = typeof next === 'function' ? next(currentState) : next
if (!resolvedState) {

View File

@ -312,9 +312,11 @@
}
targetIframe.style.display =
targetIframe.style.display === "none" ? "block" : "none";
targetIframe.style.display === "none"
? setSvgIcon("open")
: setSvgIcon("close");
if (targetIframe.style.display === "none") {
setSvgIcon("open")
} else {
setSvgIcon("close")
}
if (targetIframe.style.display === "none") {
document.removeEventListener("keydown", handleEscKey);

View File

@ -116,7 +116,7 @@ async function getKeysFromLanguage(language) {
}
// Filter only .json files
const translationFiles = files.filter(file => /\.json$/.test(file))
const translationFiles = files.filter(file => file.endsWith('.json'))
translationFiles.forEach((file) => {
const filePath = path.join(folderPath, file)
@ -263,7 +263,7 @@ async function main() {
// Get all translation files
const i18nFolder = path.resolve(__dirname, '../i18n', language)
const files = fs.readdirSync(i18nFolder)
.filter(file => /\.json$/.test(file))
.filter(file => file.endsWith('.json'))
.map(file => file.replace(/\.json$/, ''))
.filter(f => targetFiles.length === 0 || targetFiles.includes(f))

View File

@ -206,10 +206,10 @@ export class ComponentAnalyzer {
const escapedName = ComponentAnalyzer.escapeRegExp(searchName)
const patterns = [
new RegExp(`from\\s+['\"][^'\"]*(?:/|^)${escapedName}(?:['\"/]|$)`),
new RegExp(`import\\s*\\(\\s*['\"][^'\"]*(?:/|^)${escapedName}(?:['\"/]|$)`),
new RegExp(`export\\s+(?:\\*|{[^}]*})\\s*from\\s+['\"][^'\"]*(?:/|^)${escapedName}(?:['\"/]|$)`),
new RegExp(`require\\(\\s*['\"][^'\"]*(?:/|^)${escapedName}(?:['\"/]|$)`),
new RegExp(`from\\s+['"][^'"]*(?:/|^)${escapedName}(?:['"/]|$)`),
new RegExp(`import\\s*\\(\\s*['"][^'"]*(?:/|^)${escapedName}(?:['"/]|$)`),
new RegExp(`export\\s+(?:\\*|{[^}]*})\\s*from\\s+['"][^'"]*(?:/|^)${escapedName}(?:['"/]|$)`),
new RegExp(`require\\s*\\(\\s*['"][^'"]*(?:/|^)${escapedName}(?:['"/]|$)`),
]
const visited = new Set()

View File

@ -272,9 +272,6 @@ export type DocPathWithoutLang =
| DocPathWithoutLangBase
| `${DocPathWithoutLangBase}#${string}`
// Full documentation path with language prefix
type DifyDocPath = `${DocLanguage}/${DocPathWithoutLang}`
// API Reference path translations (English -> other languages)
export const apiReferencePathTranslations: Record<string, { zh?: string; ja?: string }> = {
'/api-reference/annotations/configure-annotation-reply': { zh: '/api-reference/标注管理/配置标注回复', ja: '/api-reference/アノテーション管理/アノテーション返信を設定' },