mirror of
https://github.com/langgenius/dify.git
synced 2026-05-06 18:27:19 +08:00
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:
parent
df389eba1c
commit
a633387e9b
@ -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>
|
||||
|
||||
@ -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))
|
||||
|
||||
@ -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)) {
|
||||
|
||||
@ -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)
|
||||
|
||||
@ -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: ({
|
||||
|
||||
@ -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]} />)
|
||||
|
||||
|
||||
@ -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>
|
||||
),
|
||||
|
||||
@ -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,
|
||||
|
||||
@ -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,
|
||||
|
||||
@ -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)
|
||||
|
||||
@ -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,
|
||||
|
||||
@ -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()
|
||||
|
||||
@ -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({
|
||||
|
||||
@ -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}]')
|
||||
|
||||
@ -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) {
|
||||
|
||||
@ -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);
|
||||
|
||||
@ -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))
|
||||
|
||||
|
||||
@ -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()
|
||||
|
||||
@ -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/アノテーション管理/アノテーション返信を設定' },
|
||||
|
||||
Loading…
Reference in New Issue
Block a user