Skip to content

Commit 3402e7d

Browse files
committed
chore: fix oxlint warnings - remove redundant nullish coalescing, unused vars, and unnecessary escapes
Fixes #25189 Changes: - Remove redundant `?? {}` / `|| {}` in spread operators (spread undefined is safe) - Remove unnecessary backslash escapes in single-quoted strings - Rename unused parameter `testCode` → `_testCode` - Convert ternary statement to if/else in embed.js - Replace regex with `.endsWith()` for simpler string matching - Add safe optional chaining in test file 16 files changed, 30 insertions, 28 deletions
1 parent cb9f4bb commit 3402e7d

15 files changed

Lines changed: 29 additions & 27 deletions

File tree

sdks/nodejs-client/src/http/client.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,15 +39,15 @@ const jsonResponse = (
3939
...init,
4040
headers: {
4141
"content-type": "application/json",
42-
...(init.headers ?? {}),
42+
...init.headers,
4343
},
4444
});
4545

4646
const textResponse = (body: string, init: ResponseInit = {}): Response =>
4747
new Response(body, {
4848
...init,
4949
headers: {
50-
...(init.headers ?? {}),
50+
...init.headers,
5151
},
5252
});
5353

sdks/nodejs-client/src/index.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ const jsonResponse = (body: unknown, init: ResponseInit = {}): Response =>
1414
...init,
1515
headers: {
1616
"content-type": "application/json",
17-
...(init.headers ?? {}),
17+
...init.headers,
1818
},
1919
});
2020

web/app/components/base/markdown-with-directive/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ function buildDirectiveRehypePlugins(): PluggableList {
9191
])
9292

9393
const attributes: Record<string, AttributeDefinition[]> = {
94-
...(defaultSanitizeSchema.attributes ?? {}),
94+
...defaultSanitizeSchema.attributes,
9595
}
9696

9797
for (const [tagName, allowedAttributes] of Object.entries(DIRECTIVE_ALLOWED_TAGS))

web/app/components/base/markdown/streamdown-wrapper.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ function buildRehypePlugins(extraPlugins?: PluggableList): PluggableList {
8686
])
8787

8888
const mergedAttributes: Record<string, AttributeDefinition[]> = {
89-
...(defaultSanitizeSchema.attributes ?? {}),
89+
...defaultSanitizeSchema.attributes,
9090
}
9191

9292
for (const tag of Object.keys(ALLOWED_TAGS)) {

web/app/components/datasets/documents/detail/metadata/hooks/use-metadata-state.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ export function useMetadataState({ docDetail, onUpdate }: UseMetadataStateOption
7575
setEditStatus(true)
7676
}
7777
const cancelEdit = () => {
78-
setMetadataParams({ documentType: docType || '', metadata: { ...(docDetail?.doc_metadata || {}) } })
78+
setMetadataParams({ documentType: docType || '', metadata: { ...docDetail?.doc_metadata } })
7979
setEditStatus(!docType)
8080
if (!docType)
8181
setShowDocTypes(true)

web/app/components/plugins/plugin-detail-panel/subscription-list/__tests__/log-viewer.spec.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ describe('LogViewer', () => {
145145
})
146146

147147
it('should parse request data when it is raw JSON', () => {
148-
const log = createLog({ request: { ...createLog().request, data: '{\"hello\":1}' } })
148+
const log = createLog({ request: { ...createLog().request, data: '{"hello":1}' } })
149149

150150
render(<LogViewer logs={[log]} />)
151151

web/app/components/workflow-app/hooks/__tests__/use-workflow-run.spec.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -501,7 +501,8 @@ describe('useWorkflowRun', () => {
501501
windowWithDebugControllers.__allTriggersDebugAbortController = { abort: allTriggersAbort }
502502
const refController = new AbortController()
503503
const refAbortSpy = vi.spyOn(refController, 'abort')
504-
const { getAbortController } = mocks.mockSsePost.mock.calls.at(-1)?.[2] as {
504+
const lastCall = mocks.mockSsePost.mock.calls.at(-1)
505+
const { getAbortController } = (lastCall?.[2] ?? {}) as {
505506
getAbortController?: (controller: AbortController) => void
506507
}
507508
getAbortController?.(refController)

web/app/components/workflow/hooks/use-nodes-interactions.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1484,7 +1484,7 @@ export const useNodesInteractions = () => {
14841484
targetHandle,
14851485
type: CUSTOM_EDGE,
14861486
data: {
1487-
...(edge.data || {}),
1487+
...edge.data,
14881488
sourceType: newCurrentNode.data.type,
14891489
targetType: targetNodeForEdge.data.type,
14901490
isInIteration,
@@ -1524,7 +1524,7 @@ export const useNodesInteractions = () => {
15241524
targetHandle,
15251525
type: CUSTOM_EDGE,
15261526
data: {
1527-
...(edge.data || {}),
1527+
...edge.data,
15281528
sourceType: sourceNode.data.type,
15291529
targetType: newCurrentNode.data.type,
15301530
isInIteration: newNodeIsInIteration,

web/app/components/workflow/nodes/assigner/__tests__/integration.spec.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -320,7 +320,7 @@ describe('assigner path', () => {
320320
<VarList
321321
readonly={false}
322322
nodeId="node-1"
323-
list={[createOperation({ operation: WriteMode.set, value: '{\"a\":1}' })]}
323+
list={[createOperation({ operation: WriteMode.set, value: '{"a":1}' })]}
324324
onChange={onChange}
325325
filterVar={vi.fn(() => true)}
326326
filterToAssignedVar={vi.fn(() => true)}
@@ -332,9 +332,9 @@ describe('assigner path', () => {
332332
/>,
333333
)
334334

335-
fireEvent.change(screen.getByLabelText('code-editor'), { target: { value: '{\"a\":2}' } })
335+
fireEvent.change(screen.getByLabelText('code-editor'), { target: { value: '{"a":2}' } })
336336
expect(onChange).toHaveBeenLastCalledWith([
337-
createOperation({ operation: WriteMode.set, value: '{\"a\":2}' }),
337+
createOperation({ operation: WriteMode.set, value: '{"a":2}' }),
338338
], '{"a":2}')
339339

340340
onChange.mockClear()

web/app/components/workflow/nodes/http/components/__tests__/curl-panel.spec.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ describe('curl-panel', () => {
3232

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

3737
expect(error).toBeNull()
3838
expect(node).toMatchObject({

0 commit comments

Comments
 (0)