Skip to content

Commit 4c4e216

Browse files
committed
refactor(webapp): remove redundant React fragments
1 parent 3eb7cd5 commit 4c4e216

24 files changed

Lines changed: 538 additions & 579 deletions

File tree

.oxlintrc.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,7 @@
115115
{
116116
"files": ["apps/webapp/app/**/*.ts", "apps/webapp/app/**/*.tsx"],
117117
"rules": {
118+
"react/jsx-no-useless-fragment": "error",
118119
"react/no-unstable-nested-components": "error",
119120
"react/rules-of-hooks": "error",
120121
"trigger-runops/no-control-plane-run-graph-access": "error",

apps/webapp/app/components/ErrorDisplay.tsx

Lines changed: 10 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -34,22 +34,16 @@ export function RouteErrorDisplay(options?: ErrorDisplayOptions) {
3434
);
3535
}
3636

37-
return (
38-
<>
39-
{isRouteErrorResponse(error) ? (
40-
<ErrorDisplay
41-
title={friendlyErrorDisplay(error.status, error.statusText).title}
42-
message={
43-
error.data.message ?? friendlyErrorDisplay(error.status, error.statusText).message
44-
}
45-
{...options}
46-
/>
47-
) : error instanceof Error ? (
48-
<ErrorDisplay title={error.name} message={error.message} {...options} />
49-
) : (
50-
<ErrorDisplay title="Oops" message={JSON.stringify(error)} {...options} />
51-
)}
52-
</>
37+
return isRouteErrorResponse(error) ? (
38+
<ErrorDisplay
39+
title={friendlyErrorDisplay(error.status, error.statusText).title}
40+
message={error.data.message ?? friendlyErrorDisplay(error.status, error.statusText).message}
41+
{...options}
42+
/>
43+
) : error instanceof Error ? (
44+
<ErrorDisplay title={error.name} message={error.message} {...options} />
45+
) : (
46+
<ErrorDisplay title="Oops" message={JSON.stringify(error)} {...options} />
5347
);
5448
}
5549

apps/webapp/app/components/dashboard-agent/AskAgentButton.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ export function AskAgentButton({
2121
fallback?: React.ReactNode;
2222
}) {
2323
const available = useDashboardAgentAvailable();
24-
if (!available) return <>{fallback}</>;
24+
if (!available) return fallback;
2525

2626
const button = (
2727
<Button

apps/webapp/app/components/dashboard-agent/WhenAgentUnavailable.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,5 @@ export function WhenAgentUnavailable({ children }: { children: React.ReactNode }
66
return null;
77
}
88

9-
return <>{children}</>;
9+
return children;
1010
}

apps/webapp/app/components/primitives/Buttons.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -318,7 +318,7 @@ export function ButtonContent(props: ButtonContentPropsType) {
318318
{text}
319319
</span>
320320
) : (
321-
<>{text}</>
321+
text
322322
))}
323323

324324
{shortcut &&

apps/webapp/app/components/primitives/SegmentedControl.tsx

Lines changed: 16 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -129,25 +129,23 @@ export default function SegmentedControl({
129129
}
130130
>
131131
{({ checked }) => (
132-
<>
133-
<div
134-
className={cn(
135-
"relative flex h-full w-full items-center justify-between",
136-
variantStyle.option
137-
)}
138-
>
139-
<div className="z-10 flex h-full w-full items-center justify-center">
140-
<RadioGroup.Label as="p">{option.label}</RadioGroup.Label>
141-
</div>
142-
{checked && (
143-
<motion.div
144-
layoutId={`segmented-control-${name}`}
145-
transition={{ duration: 0.4, type: "spring" }}
146-
className={variantStyle.selected}
147-
/>
148-
)}
132+
<div
133+
className={cn(
134+
"relative flex h-full w-full items-center justify-between",
135+
variantStyle.option
136+
)}
137+
>
138+
<div className="z-10 flex h-full w-full items-center justify-center">
139+
<RadioGroup.Label as="p">{option.label}</RadioGroup.Label>
149140
</div>
150-
</>
141+
{checked && (
142+
<motion.div
143+
layoutId={`segmented-control-${name}`}
144+
transition={{ duration: 0.4, type: "spring" }}
145+
className={variantStyle.selected}
146+
/>
147+
)}
148+
</div>
151149
)}
152150
</RadioGroup.Option>
153151
))}

apps/webapp/app/components/primitives/Select.tsx

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,7 @@ export function Select<TValue extends string | string[], TItem>({
225225
{...props}
226226
/>
227227
<SelectPopover className={popoverClassName}>
228-
{!searchable && showHeading && heading && <SelectHeading render={<>{heading}</>} />}
228+
{!searchable && showHeading && heading && <SelectHeading render={<span>{heading}</span>} />}
229229
{searchable && <ComboBox placeholder={heading} shortcut={shortcut} value={searchValue} />}
230230

231231
<SelectList>
@@ -313,22 +313,20 @@ export function SelectTrigger({
313313
content = children;
314314
} else if (text !== undefined) {
315315
if (typeof text === "function") {
316-
content = <SelectValue>{(value) => <>{text(value) ?? placeholder}</>}</SelectValue>;
316+
content = <SelectValue>{(value) => text(value) ?? placeholder}</SelectValue>;
317317
} else {
318318
content = text;
319319
}
320320
} else {
321321
content = (
322322
<SelectValue>
323-
{(value) => (
324-
<>
325-
{typeof value === "string"
326-
? (value ?? placeholder)
327-
: value.length === 0
328-
? placeholder
329-
: value.join(", ")}
330-
</>
331-
)}
323+
{(value) =>
324+
typeof value === "string"
325+
? (value ?? placeholder)
326+
: value.length === 0
327+
? placeholder
328+
: value.join(", ")
329+
}
332330
</SelectValue>
333331
);
334332
}

apps/webapp/app/components/primitives/Table.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -460,7 +460,7 @@ export const TableCell = forwardRef<HTMLTableCellElement, TableCellProps>(
460460
{trailingContent}
461461
</div>
462462
) : (
463-
<>{children}</>
463+
children
464464
)}
465465
</td>
466466
);

apps/webapp/app/components/primitives/Tabs.tsx

Lines changed: 30 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -258,38 +258,36 @@ export function TabButton({
258258
ref={ref}
259259
{...props}
260260
>
261-
<>
262-
<div className={cn("flex items-center gap-1", title && "flex-1")}>
263-
<span
264-
className={cn(
265-
"transition duration-200",
266-
title
267-
? cn(
268-
headerVariants.header2.text,
269-
isActive ? "text-text-bright" : "text-text-dimmed group-hover:text-text-bright"
270-
)
271-
: "text-sm text-text-bright"
272-
)}
273-
>
274-
{props.children}
275-
</span>
276-
{shortcut && <ShortcutKey className={cn("")} shortcut={shortcut} variant={"small"} />}
277-
</div>
278-
{isActive ? (
279-
<motion.div
280-
layoutId={layoutId}
281-
transition={{ type: "spring", stiffness: 500, damping: 30 }}
282-
className={cn("h-0.5 w-full bg-indigo-500", !title && "mt-1")}
283-
/>
284-
) : (
285-
<div
286-
className={cn(
287-
"h-0.5 w-full bg-surface-control-active opacity-0 transition duration-200 group-hover:opacity-100",
288-
!title && "mt-1"
289-
)}
290-
/>
291-
)}
292-
</>
261+
<div className={cn("flex items-center gap-1", title && "flex-1")}>
262+
<span
263+
className={cn(
264+
"transition duration-200",
265+
title
266+
? cn(
267+
headerVariants.header2.text,
268+
isActive ? "text-text-bright" : "text-text-dimmed group-hover:text-text-bright"
269+
)
270+
: "text-sm text-text-bright"
271+
)}
272+
>
273+
{props.children}
274+
</span>
275+
{shortcut && <ShortcutKey className={cn("")} shortcut={shortcut} variant={"small"} />}
276+
</div>
277+
{isActive ? (
278+
<motion.div
279+
layoutId={layoutId}
280+
transition={{ type: "spring", stiffness: 500, damping: 30 }}
281+
className={cn("h-0.5 w-full bg-indigo-500", !title && "mt-1")}
282+
/>
283+
) : (
284+
<div
285+
className={cn(
286+
"h-0.5 w-full bg-surface-control-active opacity-0 transition duration-200 group-hover:opacity-100",
287+
!title && "mt-1"
288+
)}
289+
/>
290+
)}
293291
</button>
294292
);
295293
}

apps/webapp/app/components/runs/v3/TaskRunsTable.tsx

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -253,11 +253,7 @@ export function TaskRunsTable({
253253
>
254254
Duration
255255
</TableHeaderCell>
256-
{showCompute && (
257-
<>
258-
<TableHeaderCell>Compute</TableHeaderCell>
259-
</>
260-
)}
256+
{showCompute && <TableHeaderCell>Compute</TableHeaderCell>}
261257
<TableHeaderCell className="pl-4" tooltip={<MachineTooltipInfo />}>
262258
Machine
263259
</TableHeaderCell>

0 commit comments

Comments
 (0)