chore(lint): hoist inline arrays in app (jsx-no-new-array-as-prop)

This commit is contained in:
Mohamed Boudra
2026-04-23 23:15:11 +07:00
parent 8852d62cef
commit 5a78561dc8
5 changed files with 28 additions and 11 deletions

View File

@@ -1,3 +1,4 @@
import { useMemo } from "react";
import { View } from "react-native";
import { StyleSheet, useUnistyles } from "react-native-unistyles";
import {
@@ -41,7 +42,12 @@ export function AgentStatusDot({
return null;
}
return <View style={[styles.dot, { backgroundColor: color }]} />;
return <AgentStatusDotView color={color} />;
}
function AgentStatusDotView({ color }: { color: string }) {
const dotStyle = useMemo(() => [styles.dot, { backgroundColor: color }], [color]);
return <View style={dotStyle} />;
}
function isAgentLifecycleStatus(value: string): value is AgentLifecycleStatus {

View File

@@ -1,4 +1,4 @@
import { useState } from "react";
import { useMemo, useState } from "react";
import { View, Text } from "react-native";
import { StyleSheet } from "react-native-unistyles";
import Animated from "react-native-reanimated";
@@ -22,6 +22,11 @@ export function ArchivedAgentCallout({ serverId, agentId }: ArchivedAgentCallout
const { style: keyboardAnimatedStyle } = useKeyboardShiftStyle({ mode: "translate" });
const containerStyle = useMemo(
() => [styles.container, { paddingBottom: insets.bottom }, keyboardAnimatedStyle],
[insets.bottom, keyboardAnimatedStyle],
);
async function handleUnarchive() {
if (!client || !isConnected || isUnarchiving) return;
setIsUnarchiving(true);
@@ -34,9 +39,7 @@ export function ArchivedAgentCallout({ serverId, agentId }: ArchivedAgentCallout
}
return (
<Animated.View
style={[styles.container, { paddingBottom: insets.bottom }, keyboardAnimatedStyle]}
>
<Animated.View style={containerStyle}>
<View style={styles.inputAreaContainer}>
<View style={styles.inputAreaContent}>
<View style={styles.callout}>

View File

@@ -1,4 +1,4 @@
import { useCallback } from "react";
import { useCallback, useMemo } from "react";
import { View, Text, ActivityIndicator, Pressable } from "react-native";
import { StyleSheet, useUnistyles } from "react-native-unistyles";
import { ChevronDown, Info, MoreVertical } from "lucide-react-native";
@@ -44,6 +44,8 @@ export function GitActionsSplitButton({ gitActions, hideLabels }: GitActionsSpli
[theme.colors.foreground, toast],
);
const overflowMenuButtonStyle = useMemo(() => [styles.iconButton, styles.overflowMenuButton], []);
return (
<View style={styles.row}>
{gitActions.primary ? (
@@ -132,7 +134,7 @@ export function GitActionsSplitButton({ gitActions, hideLabels }: GitActionsSpli
<DropdownMenuTrigger
testID="changes-overflow-menu"
hitSlop={8}
style={[styles.iconButton, styles.overflowMenuButton]}
style={overflowMenuButtonStyle}
accessibilityRole="button"
accessibilityLabel="More actions"
>

View File

@@ -8,6 +8,10 @@ import {
useIsolatedBottomSheetVisibility,
} from "./isolated-bottom-sheet-modal";
const SNAP_POINTS_50: (string | number)[] = ["50%"];
const SNAP_POINTS_60: (string | number)[] = ["60%"];
const SNAP_POINTS_90: (string | number)[] = ["90%"];
const { modalMethods, modalProps } = vi.hoisted(() => ({
modalMethods: {
present: vi.fn(),
@@ -57,7 +61,7 @@ function Harness({ visible, onClose }: { visible: boolean; onClose: () => void }
<IsolatedBottomSheetModal
ref={sheetRef}
index={0}
snapPoints={["50%"]}
snapPoints={SNAP_POINTS_50}
onChange={handleSheetChange}
>
<div>Sheet content</div>
@@ -112,8 +116,8 @@ describe("IsolatedBottomSheetModal", () => {
it("allows nested sheets inside a parent sheet without creating a sibling provider", () => {
const { getAllByTestId } = render(
<IsolatedBottomSheetModal index={0} snapPoints={["90%"]}>
<IsolatedBottomSheetModal index={0} snapPoints={["60%"]} onChange={() => {}}>
<IsolatedBottomSheetModal index={0} snapPoints={SNAP_POINTS_90}>
<IsolatedBottomSheetModal index={0} snapPoints={SNAP_POINTS_60} onChange={() => {}}>
<div>Nested model picker</div>
</IsolatedBottomSheetModal>
</IsolatedBottomSheetModal>,

View File

@@ -7,13 +7,15 @@ export interface PairDeviceModalProps {
testID?: string;
}
const SNAP_POINTS: string[] = ["82%", "94%"];
export function PairDeviceModal({ visible, onClose, testID }: PairDeviceModalProps) {
return (
<AdaptiveModalSheet
title="Pair a device"
visible={visible}
onClose={onClose}
snapPoints={["82%", "94%"]}
snapPoints={SNAP_POINTS}
desktopMaxWidth={640}
testID={testID}
>